Commit c797ecb5d54370216ce00075ac77a862c6ec850e
1 parent
dba82457
Exists in
master
and in
6 other branches
Add: active page ('/ativar/:token') - issue #44
Showing
5 changed files
with
117 additions
and
3 deletions
Show diff stats
src/app/components/auth/auth.service.js
... | ... | @@ -66,8 +66,7 @@ |
66 | 66 | |
67 | 67 | function activate (code) { |
68 | 68 | var url = PATH.host + '/api/v1/activate'; |
69 | - var encodedData = 'private_token=' + API.token; | |
70 | - encodedData += '&activation_code=' + code; | |
69 | + var encodedData = 'activation_code=' + code; | |
71 | 70 | |
72 | 71 | return $http |
73 | 72 | .patch(url, encodedData) | ... | ... |
src/app/index.route.js
... | ... | @@ -42,6 +42,17 @@ |
42 | 42 | } |
43 | 43 | } |
44 | 44 | }) |
45 | + .state('ativar', { | |
46 | + url: '/ativar/:activation_code', | |
47 | + ncyBreadcrumb: {label: 'Ativar e-mail'}, | |
48 | + views: { | |
49 | + 'main': { | |
50 | + templateUrl: 'app/pages/auth/active.html', | |
51 | + controller: 'ActivePageController', | |
52 | + controllerAs: 'pageActive' | |
53 | + } | |
54 | + } | |
55 | + }) | |
45 | 56 | .state('recuperar', { |
46 | 57 | url: '/recuperar', |
47 | 58 | ncyBreadcrumb: {label: 'Recuperar senha'}, | ... | ... |
... | ... | @@ -0,0 +1,56 @@ |
1 | +(function() { | |
2 | + 'use strict'; | |
3 | + | |
4 | + angular | |
5 | + .module('dialoga') | |
6 | + .controller('ActivePageController', ActivePageController); | |
7 | + | |
8 | + /** @ngInject */ | |
9 | + function ActivePageController(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 | + vm.doActivation(); | |
18 | + | |
19 | + vm.$log.debug('ActivePageController'); | |
20 | + } | |
21 | + | |
22 | + ActivePageController.prototype.init = function() { | |
23 | + var vm = this; | |
24 | + | |
25 | + // init variables | |
26 | + vm.loading = true; | |
27 | + vm.activation_code = vm.$state.params.activation_code; | |
28 | + }; | |
29 | + | |
30 | + ActivePageController.prototype.doActivation = function() { | |
31 | + var vm = this; | |
32 | + | |
33 | + vm.AuthService.activate(vm.activation_code). | |
34 | + then(function(response){ | |
35 | + // SUCCESS | |
36 | + vm.$log.info('response', response); | |
37 | + | |
38 | + vm.successMessageTitle = 'Pronto!'; | |
39 | + vm.successMessageContent = 'Conta ativada com sucesso!'; | |
40 | + }, function(response){ | |
41 | + // ERROR | |
42 | + vm.$log.error('response', response); | |
43 | + | |
44 | + vm.errorMessageTitle = 'Erro!'; | |
45 | + | |
46 | + // Server Error | |
47 | + if(response.status >= 500 || response.status < 600){ | |
48 | + vm.errorMessageContent = 'Código de ativação incorreto.'; | |
49 | + } | |
50 | + }) | |
51 | + .finally(function(data){ | |
52 | + vm.$log.debug('finally', data); | |
53 | + vm.loading = false; | |
54 | + }); | |
55 | + }; | |
56 | +})(); | ... | ... |
... | ... | @@ -0,0 +1,48 @@ |
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> | |
28 | + </div> | |
29 | + </div> | |
30 | + </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> | |
41 | + </div> | |
42 | + </div> | |
43 | + </div> | |
44 | + </div> | |
45 | + <br> | |
46 | + </div> | |
47 | + </div> | |
48 | +</section> | ... | ... |
src/app/pages/auth/change.html