Commit fbb93b59fbaadfcc2fde91b4c49b00735afc8d0f

Authored by Leonardo Merlin
1 parent 5f1c6404

Improve auth feedback.

src/app/pages/auth/auth.controller.js
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 vm.terms = null; 35 vm.terms = null;
36 vm.loadingTerms = null; 36 vm.loadingTerms = null;
37 vm.delay = 3; // segundos 37 vm.delay = 3; // segundos
38 - vm.startRedirect = null; 38 + vm.countdown = 0;
39 39
40 vm.search = vm.$location.search(); 40 vm.search = vm.$location.search();
41 var redirect = vm.search.redirect_uri || ''; 41 var redirect = vm.search.redirect_uri || '';
@@ -89,12 +89,8 @@ @@ -89,12 +89,8 @@
89 // TODO: mensagens de sucesso 89 // TODO: mensagens de sucesso
90 // 'Cadastro efetuado com sucesso.' 90 // 'Cadastro efetuado com sucesso.'
91 // 'Verifique seu email para confirmar o cadastro.' 91 // 'Verifique seu email para confirmar o cadastro.'
92 -  
93 - vm.startRedirect = true;  
94 - vm.$timeout(function(){  
95 - vm.redirectBack();  
96 - vm.startRedirect = false;  
97 - }, vm.delay * 1000); 92 + vm.successMessage = '<h3>Cadastro efetuado com sucesso.</h3>' + '<p>Verifique seu <b>email</b> para confirmar o cadastro.</p>';
  93 + vm.redirectBack();
98 }, function(response){ 94 }, function(response){
99 vm.$log.debug('register error.response', response); 95 vm.$log.debug('register error.response', response);
100 96
@@ -110,11 +106,8 @@ @@ -110,11 +106,8 @@
110 // handle view 106 // handle view
111 vm.$log.debug('user', user); 107 vm.$log.debug('user', user);
112 108
113 - vm.startRedirect = true;  
114 - vm.$timeout(function(){  
115 - vm.redirectBack();  
116 - vm.startRedirect = false;  
117 - }, vm.delay * 1000); 109 + vm.successMessage = 'Login efetuado com sucesso!';
  110 + vm.redirectBack();
118 }, function() { 111 }, function() {
119 // handle view 112 // handle view
120 }); 113 });
@@ -128,24 +121,39 @@ @@ -128,24 +121,39 @@
128 return; 121 return;
129 } 122 }
130 123
131 - var state = vm.params.state;  
132 - switch(state){  
133 - case 'inicio':  
134 - vm.$state.go(state, {  
135 - event_id: vm.params.event_id,  
136 - task: vm.params.task  
137 - });  
138 - break;  
139 - case 'programa':  
140 - vm.$state.go(state, {  
141 - slug: vm.params.slug,  
142 - task: vm.params.task  
143 - });  
144 - break;  
145 - default:  
146 - vm.$log.debug('State not handled yet:', state);  
147 - break;  
148 - } 124 + // start countdown
  125 + vm.countdown = vm.delay;
  126 + (function countdown(){
  127 + vm.$timeout(function(){
  128 + vm.countdown--;
  129 + vm.$log.debug('vm.countdown', vm.countdown);
  130 + if(vm.countdown > 0){
  131 + countdown();
  132 + }
  133 + }, 1000);
  134 + })();
  135 +
  136 + vm.$timeout(function(){
  137 + var state = vm.params.state;
  138 + switch(state){
  139 + case 'inicio':
  140 + vm.$state.go(state, {
  141 + event_id: vm.params.event_id,
  142 + task: vm.params.task
  143 + });
  144 + break;
  145 + case 'programa':
  146 + vm.$state.go(state, {
  147 + slug: vm.params.slug,
  148 + task: vm.params.task
  149 + });
  150 + break;
  151 + default:
  152 + vm.$log.debug('State not handled yet:', state);
  153 + break;
  154 + }
  155 + }, vm.delay * 1000);
  156 +
149 } 157 }
150 158
151 })(); 159 })();
src/app/pages/auth/signin.html
@@ -13,9 +13,12 @@ @@ -13,9 +13,12 @@
13 <div class="col-sm-8 col-sm-offset-2"> 13 <div class="col-sm-8 col-sm-offset-2">
14 14
15 <div> 15 <div>
16 - <h3>Você está logado!</h3>  
17 - <div ng-if="vm.hasRedirect && vm.startRedirect">  
18 - Você será redirecionado em menos de <b>3 segundos</b>.... 16 + <h3 ng-if="!pageSignin.successMessage">Você está logado!</h3>
  17 + <h3 ng-if="pageSignin.successMessage" ng-bind-html="pageSignin.successMessage"></h3>
  18 + <div ng-if="pageSignin.countdown > 0">
  19 + <p>
  20 + Você será redirecionado em menos de <b>{{pageSignin.countdown}} segundos</b>...
  21 + </p>
19 </div> 22 </div>
20 <button type="button" ng-click="pageSignin.onClickLogout()" class="btn btn-primary">Sair</button> 23 <button type="button" ng-click="pageSignin.onClickLogout()" class="btn btn-primary">Sair</button>
21 </div> 24 </div>