Commit 4ff60ea5bd5c6fbd486be09164ac1eb70e60c932
Exists in
master
and in
6 other branches
Merge branch 'fix-issues'
Showing
9 changed files
with
236 additions
and
149 deletions
Show diff stats
.editorconfig
src/app/components/auth/auth.service.js
... | ... | @@ -112,11 +112,11 @@ |
112 | 112 | }); |
113 | 113 | } |
114 | 114 | |
115 | - function changePassword (code, newPassword, newPasswordConfirmation){ | |
115 | + function changePassword (data){ | |
116 | 116 | var url = PATH.host + '/api/v1/new_password'; |
117 | - var encodedData = 'code=' + code; | |
118 | - encodedData += '&password=' + newPassword; | |
119 | - encodedData += '&password_confirmation=' + newPasswordConfirmation; | |
117 | + var encodedData = 'code=' + data.code; | |
118 | + encodedData += '&password=' + data.newPassword; | |
119 | + encodedData += '&password_confirmation=' + data.newPasswordConfirmation; | |
120 | 120 | |
121 | 121 | return $http |
122 | 122 | .patch(url, encodedData) | ... | ... |
src/app/index.route.js
... | ... | @@ -64,14 +64,14 @@ |
64 | 64 | } |
65 | 65 | } |
66 | 66 | }) |
67 | - .state('alterar', { | |
68 | - url: '/alterar', | |
69 | - ncyBreadcrumb: {label: 'Alterar'}, | |
67 | + .state('nova-senha', { | |
68 | + url: '/nova-senha/:token', | |
69 | + ncyBreadcrumb: {label: 'Nova senha'}, | |
70 | 70 | views: { |
71 | 71 | 'main': { |
72 | - templateUrl: 'app/pages/auth/change.html', | |
73 | - controller: 'AuthPageController', | |
74 | - controllerAs: 'pageAuth' | |
72 | + templateUrl: 'app/pages/auth/new-password.html', | |
73 | + controller: 'NewPasswordPageController', | |
74 | + controllerAs: 'pageNewPassword' | |
75 | 75 | } |
76 | 76 | } |
77 | 77 | }) | ... | ... |
src/app/pages/auth/active.html
1 | -<div class="container"> | |
2 | - <div class="row"> | |
3 | - <div class="col-sm-12"> | |
4 | - <h2>Ativar conta</h2> | |
5 | - </div> | |
6 | - </div> | |
7 | -</div> | |
8 | -<section role="main" class="section-gray"> | |
9 | - <div class="container"> | |
10 | - <div class="row"> | |
11 | - <br> | |
12 | - <div class="col-sm-8 col-sm-offset-2"> | |
13 | - | |
14 | - <div ng-if="pageActive.loading"> | |
15 | - <h3>Aguarde...</h3> | |
16 | - <p>Estamos ativando a sua conta ({{::pageActive.activation_code}}).</p> | |
17 | - </div> | |
18 | - | |
19 | - <div ng-if="pageActive.successMessageTitle"> | |
20 | - <show-message | |
21 | - type="'success'" | |
22 | - message="pageActive.successMessageTitle" | |
23 | - description="pageActive.successMessageContent" | |
24 | - ></show-message> | |
25 | - <div class="row"> | |
26 | - <div class="col-sm-8 col-sm-offset-4"> | |
27 | - <p><a ui-sref="entrar" class="btn btn-default">Entrar</a></p> | |
1 | +<div class="page--auth-active"> | |
2 | + <div class="container"> | |
3 | + <div class="row"> | |
4 | + <div class="col-sm-12"> | |
5 | + <h2>Ativar conta</h2> | |
28 | 6 | </div> |
29 | - </div> | |
30 | 7 | </div> |
31 | - | |
32 | - <div ng-if="pageActive.errorMessageTitle"> | |
33 | - <show-message | |
34 | - type="'error'" | |
35 | - message="pageActive.errorMessageTitle" | |
36 | - description="pageActive.errorMessageContent" | |
37 | - ></show-message> | |
38 | - <div class="row"> | |
39 | - <div class="col-sm-8 col-sm-offset-4"> | |
40 | - <p><a ui-sref="reenviar-email" class="btn btn-default">Re-enviar e-mail de confirmação</a></p> | |
8 | + </div> | |
9 | + <section role="main" class="section-gray vertical-padding"> | |
10 | + <div class="container"> | |
11 | + <div class="row"> | |
12 | + <div class="col-sm-8 col-sm-offset-2"> | |
13 | + <div ng-if="pageActive.loading"> | |
14 | + <h3>Aguarde...</h3> | |
15 | + <p>Estamos ativando a sua conta ({{::pageActive.activation_code}}).</p> | |
16 | + </div> | |
17 | + <div ng-if="pageActive.successMessageTitle"> | |
18 | + <show-message type="'success'" message="pageActive.successMessageTitle" description="pageActive.successMessageContent"></show-message> | |
19 | + <div class="row"> | |
20 | + <div class="col-sm-8 col-sm-offset-4"> | |
21 | + <p><a ui-sref="entrar" class="btn btn-default">Entrar</a></p> | |
22 | + </div> | |
23 | + </div> | |
24 | + </div> | |
25 | + <div ng-if="pageActive.errorMessageTitle"> | |
26 | + <show-message type="'error'" message="pageActive.errorMessageTitle" description="pageActive.errorMessageContent"></show-message> | |
27 | + <div class="row"> | |
28 | + <div class="col-sm-8 col-sm-offset-4"> | |
29 | + <p><a ui-sref="reenviar-email" class="btn btn-default">Re-enviar e-mail de confirmação</a></p> | |
30 | + </div> | |
31 | + </div> | |
32 | + </div> | |
33 | + </div> | |
41 | 34 | </div> |
42 | - </div> | |
43 | 35 | </div> |
44 | - </div> | |
45 | - <br> | |
46 | - </div> | |
47 | - </div> | |
48 | -</section> | |
36 | + </section> | |
37 | +</div> | |
49 | 38 | \ No newline at end of file | ... | ... |
src/app/pages/auth/auth.controller.js
... | ... | @@ -132,10 +132,7 @@ |
132 | 132 | AuthPageController.prototype.submitSignup = function($event, credentials) { |
133 | 133 | var vm = this; |
134 | 134 | |
135 | - var target = $event.target; | |
136 | - var $target = angular.element(target); | |
137 | - var $captcha = $target.find('[name="txtToken_captcha_serpro_gov_br"]'); | |
138 | - credentials.txtToken_captcha_serpro_gov_br = $captcha.val(); | |
135 | + credentials.txtToken_captcha_serpro_gov_br = getCaptchaValFromEvent($event); | |
139 | 136 | |
140 | 137 | vm.AuthService.register(credentials) |
141 | 138 | .then(function(/*response*/) { |
... | ... | @@ -204,25 +201,27 @@ |
204 | 201 | AuthPageController.prototype.submitRecover = function($event, recoverForm) { |
205 | 202 | var vm = this; |
206 | 203 | |
204 | + // init vars | |
205 | + vm.loadingSubmitRecover = true; | |
206 | + | |
207 | 207 | // get form data |
208 | 208 | var data = { |
209 | 209 | login: recoverForm.login.$modelValue, |
210 | - captcha_text: recoverForm.captcha_text.$modelValue | |
210 | + captcha_text: recoverForm.captcha_text.$modelValue, | |
211 | + txtToken_captcha_serpro_gov_br: getCaptchaValFromEvent($event) | |
211 | 212 | }; |
212 | 213 | |
213 | - // get captcha token | |
214 | - var target = $event.target; | |
215 | - var $target = angular.element(target); | |
216 | - var $captcha = $target.find('[name="txtToken_captcha_serpro_gov_br"]'); | |
217 | - data.txtToken_captcha_serpro_gov_br = $captcha.val(); | |
218 | - | |
219 | - vm.AuthService.forgotPassword(data).then(function(response) { | |
214 | + var promiseRequest = vm.AuthService.forgotPassword(data); | |
215 | + | |
216 | + // SUCCES | |
217 | + promiseRequest.then(function(response) { | |
220 | 218 | vm.$log.debug('recover success.response', response); |
221 | 219 | |
222 | 220 | vm.recoverSuccess = true; |
223 | - // vm._startRedirect(); | |
221 | + }); | |
224 | 222 | |
225 | - }, function(response){ | |
223 | + // ERROR | |
224 | + promiseRequest.catch(function(response){ | |
226 | 225 | vm.$log.debug('recover error.response', response); |
227 | 226 | |
228 | 227 | vm.recoverError = true; |
... | ... | @@ -239,8 +238,11 @@ |
239 | 238 | if (response.status >= 500 && response.status < 600){ |
240 | 239 | vm.internalError = true; |
241 | 240 | } |
242 | - }).catch(function(error){ | |
243 | - vm.$log.debug('recover catch.error', error); | |
241 | + }); | |
242 | + | |
243 | + // ALWAYS | |
244 | + promiseRequest.finally(function(){ | |
245 | + vm.loadingSubmitRecover = false; | |
244 | 246 | }); |
245 | 247 | }; |
246 | 248 | |
... | ... | @@ -250,14 +252,11 @@ |
250 | 252 | // get form data |
251 | 253 | var data = { |
252 | 254 | login: confirmationForm.login.$modelValue, |
253 | - captcha_text: confirmationForm.captcha_text.$modelValue | |
255 | + captcha_text: confirmationForm.captcha_text.$modelValue, | |
256 | + txtToken_captcha_serpro_gov_br: getCaptchaValFromEvent($event) | |
254 | 257 | }; |
255 | 258 | |
256 | 259 | // get captcha token |
257 | - var target = $event.target; | |
258 | - var $target = angular.element(target); | |
259 | - var $captcha = $target.find('[name="txtToken_captcha_serpro_gov_br"]'); | |
260 | - data.txtToken_captcha_serpro_gov_br = $captcha.val(); | |
261 | 260 | |
262 | 261 | vm.AuthService.resendConfirmation(data) |
263 | 262 | .then(function(response) { |
... | ... | @@ -370,4 +369,8 @@ |
370 | 369 | var url = 'http://login.dialoga.gov.br/plugin/oauth_client/google_oauth2?oauth_client_popup=true&id=' + vm.APP.google_app_id; |
371 | 370 | vm.$window.oauthClientAction(url); |
372 | 371 | }; |
372 | + | |
373 | + function getCaptchaValFromEvent($event){ | |
374 | + return angular.element($event.target).find('[name="txtToken_captcha_serpro_gov_br"]').val(); | |
375 | + } | |
373 | 376 | })(); | ... | ... |
src/app/pages/auth/change.html
... | ... | @@ -1,71 +0,0 @@ |
1 | -<div class="container"> | |
2 | - <div class="row"> | |
3 | - <div class="col-sm-12"> | |
4 | - <h2>Esqueci minha senha</h2> | |
5 | - <h5>Agora é só criar e confirmar sua nova senha.</h5> | |
6 | - </div> | |
7 | - </div> | |
8 | -</div> | |
9 | -<section role="main" class="section-gray"> | |
10 | - <div class="container"> | |
11 | - <div class="row"> | |
12 | - <div ng-if="pageAuth.currentUser"> | |
13 | - <div class="row"> | |
14 | - <div class="col-sm-8 col-sm-offset-2"> | |
15 | - <h3>Você está logado!</h3> | |
16 | - <button | |
17 | - type="button" | |
18 | - ng-click="pageAuth.onClickLogout()" | |
19 | - class="btn btn-primary">Sair</button> | |
20 | - </div> | |
21 | - </div> | |
22 | - </div> | |
23 | - <div ng-if="!pageAuth.currentUser"> | |
24 | - <br> | |
25 | - <div class="col-sm-8 col-sm-offset-2"> | |
26 | - <div class="row"> | |
27 | - <div class="col-md-12"> | |
28 | - <form name="changePassForm" ng-submit=""> | |
29 | - <div class="row"> | |
30 | - <div class="col-md-6"> | |
31 | - <div class="form-group"> | |
32 | - <label for="inputPassword">Senha*</label> | |
33 | - <input type="password" id="inputPassword" name="inputPassword" class="form-control input-lg" ng-class="{ 'has-error' : changePassForm.inputPassword.$invalid && changePassForm.inputPassword.$touched }" ng-model="password" required> | |
34 | - <validation-messages field="changePassForm.inputPassword"/> | |
35 | - </div> | |
36 | - </div> | |
37 | - <div class="col-md-6"> | |
38 | - <div class="form-group"> | |
39 | - <label for="inputRepeatPassword">Confirmar senha*</label> | |
40 | - <input | |
41 | - type="password" id="inputRepeatPassword" name="inputRepeatPassword" class="form-control input-lg" ng-class="{ 'has-error' : changePassForm.inputRepeatPassword.$invalid && changePassForm.inputRepeatPassword.$touched }" ng-model="repeatPassword" required> | |
42 | - <validation-messages field="changePassForm.inputRepeatPassword"/> | |
43 | - </div> | |
44 | - </div> | |
45 | - </div> | |
46 | - <div class="row"> | |
47 | - <div class="col-sm-12"> | |
48 | - <span> | |
49 | - A senha deve ter 6 ou mais caracteres e conter números e letras. | |
50 | - </span> | |
51 | - </div> | |
52 | - </div> | |
53 | - <br> | |
54 | - <div class="row"> | |
55 | - <div class="col-md-6 col-sm-offset-3"> | |
56 | - <div class="form-group"> | |
57 | - <button | |
58 | - class="btn btn-lg btn-block btn-submit" | |
59 | - type="submit">Confirmar alteração de senha</button> | |
60 | - </div> | |
61 | - </div> | |
62 | - </div> | |
63 | - </form> | |
64 | - </div> | |
65 | - </div> | |
66 | - </div> | |
67 | - <br> | |
68 | - </div> | |
69 | - </div> | |
70 | - </div> | |
71 | -</section> |
... | ... | @@ -0,0 +1,83 @@ |
1 | +<div class="page--new-password"> | |
2 | + <div class="container"> | |
3 | + <div class="row"> | |
4 | + <div class="col-sm-12"> | |
5 | + <h2>Cadastrar nova senha</h2> | |
6 | + <h5>Agora é só informar e confirmar sua nova senha.</h5> | |
7 | + </div> | |
8 | + </div> | |
9 | + </div> | |
10 | + <section role="main" class="section-gray vertical-padding"> | |
11 | + <div class="container"> | |
12 | + <div class="row"> | |
13 | + <div class="col-sm-8 col-sm-offset-2"> | |
14 | + <div ng-if="pageNewPassword.loading"> | |
15 | + <h3>Aguarde...</h3> | |
16 | + <p>Estamos configurando a sua nova senha.</p> | |
17 | + </div> | |
18 | + <div ng-if="!pageNewPassword.loading"> | |
19 | + <div ng-if="pageNewPassword.submitNewPasswordSuccess"> | |
20 | + <div class="alert alert-success"> | |
21 | + <strong>Feito!</strong> Sua senha foi configurada com sucesso. | |
22 | + </div> | |
23 | + </div> | |
24 | + <div ng-if="pageNewPassword.submitNewPasswordError"> | |
25 | + <div class="alert alert-danger"> | |
26 | + <strong>Erro!</strong> {{::pageNewPassword.submitNewPasswordErrorMessage}} | |
27 | + </div> | |
28 | + <p>Tente novamente ou <a ui-sref="duvidas">entre em contato</a>.</p> | |
29 | + </div> | |
30 | + <form | |
31 | + novalidate | |
32 | + name="newPasswordForm" | |
33 | + ng-submit="newPasswordForm.$valid && pageNewPassword.submitNewPassword($event, newPasswordForm)"> | |
34 | + <input type="hidden" name="code" value="{{::pageNewPassword.token}}" /> | |
35 | + <div class="row"> | |
36 | + <div class="col-md-6"> | |
37 | + <div class="form-group"> | |
38 | + <label for="newPassword">Senha*</label> | |
39 | + <input type="password" id="newPassword" name="newPassword" class="form-control input-lg" ng-class="{ 'has-error' : newPasswordForm.newPassword.$invalid && newPasswordForm.newPassword.$touched }" ng-minlength="6" ng-model="newPassword" required> | |
40 | + <validation-messages field="newPasswordForm.newPassword"></validation-messages> | |
41 | + </div> | |
42 | + </div> | |
43 | + <div class="col-md-6"> | |
44 | + <div class="form-group"> | |
45 | + <label for="newPasswordConfirmation">Confirmar senha*</label> | |
46 | + <input type="password" id="newPasswordConfirmation" name="newPasswordConfirmation" class="form-control input-lg" ng-class="{ 'has-error' : newPasswordForm.newPasswordConfirmation.$invalid && newPasswordForm.newPasswordConfirmation.$touched }" ng-minlength="6" ng-model="newPasswordConfirmation" required> | |
47 | + <validation-messages field="newPasswordForm.newPasswordConfirmation"></validation-messages> | |
48 | + </div> | |
49 | + </div> | |
50 | + </div> | |
51 | + <div class="row"> | |
52 | + <div class="col-sm-12" ng-show="(newPasswordForm.newPassword.$viewValue.length > 0 && newPasswordForm.newPasswordConfirmation.$viewValue.length > 0) && (newPasswordForm.newPassword.$viewValue !== newPasswordForm.newPasswordConfirmation.$viewValue)"> | |
53 | + <div class="error-message"> | |
54 | + As senhas estão diferentes. | |
55 | + </div> | |
56 | + </div> | |
57 | + <div class="col-sm-12"> | |
58 | + <div class="text" ng-show="newPasswordForm.newPassword.$viewValue.length > 0 && newPasswordForm.newPassword.$viewValue.length < 6"> | |
59 | + <div class="error-message"> | |
60 | + A senha deve ter 6 ou mais caracteres e conter números e letras. | |
61 | + </div> | |
62 | + </div> | |
63 | + </div> | |
64 | + </div> | |
65 | + <br> | |
66 | + <div class="row"> | |
67 | + <div class="col-md-6 col-sm-offset-3"> | |
68 | + <div class="form-group"> | |
69 | + <button | |
70 | + class="btn btn-lg btn-block btn-submit" | |
71 | + type="submit" | |
72 | + ng-disabled="newPasswordForm.$invalid || ((newPasswordForm.newPassword.$viewValue.length > 0 && newPasswordForm.newPasswordConfirmation.$viewValue.length > 0) && (newPasswordForm.newPassword.$viewValue !== newPasswordForm.newPasswordConfirmation.$viewValue))" | |
73 | + >Confirmar alteração de senha</button> | |
74 | + </div> | |
75 | + </div> | |
76 | + </div> | |
77 | + </form> | |
78 | + </div> | |
79 | + </div> | |
80 | + </div> | |
81 | + </div> | |
82 | + </section> | |
83 | +</div> | ... | ... |
... | ... | @@ -0,0 +1,82 @@ |
1 | +(function() { | |
2 | + 'use strict'; | |
3 | + | |
4 | + angular | |
5 | + .module('dialoga') | |
6 | + .controller('NewPasswordPageController', NewPasswordPageController); | |
7 | + | |
8 | + /** @ngInject */ | |
9 | + function NewPasswordPageController(AuthService, $state, $log) { | |
10 | + var vm = this; | |
11 | + | |
12 | + vm.AuthService = AuthService; | |
13 | + vm.$state = $state; | |
14 | + vm.$log = $log; | |
15 | + | |
16 | + vm.init(); | |
17 | + | |
18 | + vm.$log.debug('NewPasswordPageController'); | |
19 | + } | |
20 | + | |
21 | + NewPasswordPageController.prototype.init = function() { | |
22 | + var vm = this; | |
23 | + | |
24 | + // init variables | |
25 | + vm.loading = false; | |
26 | + vm.submitNewPasswordSuccess = false; | |
27 | + vm.submitNewPasswordError = false; | |
28 | + vm.token = vm.$state.params.token; | |
29 | + }; | |
30 | + | |
31 | + NewPasswordPageController.prototype.submitNewPassword = function($event, newPasswordForm) { | |
32 | + var vm = this; | |
33 | + | |
34 | + if(!newPasswordForm.$valid){ | |
35 | + vm.$log.warn('Form validation: fail.'); | |
36 | + return; | |
37 | + } | |
38 | + | |
39 | + // init vars | |
40 | + vm.loading = true; | |
41 | + vm.submitNewPasswordSuccess = false; | |
42 | + vm.submitNewPasswordError = false; | |
43 | + | |
44 | + // get form data | |
45 | + var data = { | |
46 | + code: newPasswordForm.code, | |
47 | + newPassword: newPasswordForm.newPassword.$modelValue, | |
48 | + newPasswordConfirmation: newPasswordForm.newPasswordConfirmation.$modelValue | |
49 | + }; | |
50 | + | |
51 | + // Create the promise request | |
52 | + var promiseRequest = vm.AuthService.changePassword(data); | |
53 | + | |
54 | + promiseRequest | |
55 | + .then(function(response) { | |
56 | + vm.$log.debug('new password success:', response); | |
57 | + | |
58 | + vm.submitNewPasswordSuccess = true; | |
59 | + }) | |
60 | + .catch(function(response){ | |
61 | + vm.$log.debug('new password error:', response); | |
62 | + | |
63 | + vm.submitNewPasswordError = true; | |
64 | + vm.submitNewPasswordErrorMessage = response.data.message || 'Não foi possível configurar nova senha.'; | |
65 | + | |
66 | + // Client Error | |
67 | + // if (response.status >= 400 && response.status < 500){ | |
68 | + // if(response.status === 404){ | |
69 | + // vm.submitNewPasswordErrorMessage = 'Não foi possível configurar nova senha.'; | |
70 | + // } | |
71 | + // } | |
72 | + | |
73 | + // Server Error | |
74 | + if (response.status >= 500 && response.status < 600){ | |
75 | + vm.internalError = true; | |
76 | + } | |
77 | + }) | |
78 | + .finally(function(){ | |
79 | + vm.loading = false; | |
80 | + }); | |
81 | + }; | |
82 | +})(); | ... | ... |
src/app/pages/auth/recover.html
... | ... | @@ -3,9 +3,7 @@ |
3 | 3 | <div class="row"> |
4 | 4 | <div class="col-sm-12"> |
5 | 5 | <h2>Esqueci minha senha</h2> |
6 | - <h5> | |
7 | - Calma, podemos ajudar! Informe o seu e-mail que a gente envia um link de alteração. | |
8 | - </h5> | |
6 | + <h5>Calma, podemos ajudar! Informe o seu e-mail que a gente envia um link de alteração.</h5> | |
9 | 7 | </div> |
10 | 8 | </div> |
11 | 9 | </div> | ... | ... |