Commit 62aaf55a755f423d07a373a0a9dc26f2f20d2383

Authored by Leonardo Merlin
1 parent 53924e25

Refact login -> auth

src/app/partials/article/article.service.js
... ... @@ -13,7 +13,7 @@
13 13 var _savedAbstract = null;
14 14  
15 15 var service = {
16   - apiArticles: api.host + 'articles/',
  16 + apiArticles: api.host + '/api/v1/articles/',
17 17 getHome: getHome,
18 18 setHomeAbstract: setHomeAbstract,
19 19 getHomeAbstract: getHomeAbstract
... ...
src/app/partials/auth/auth.controller.js 0 → 100644
... ... @@ -0,0 +1,44 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('dialoga')
  6 + .controller('AuthController', AuthController);
  7 +
  8 + /** @ngInject */
  9 + function AuthController($rootScope, AUTH_EVENTS, AuthService, Session, $log) {
  10 + $log.debug('AuthController');
  11 +
  12 + var vm = this;
  13 +
  14 + vm.$rootScope = $rootScope;
  15 + vm.AUTH_EVENTS = AUTH_EVENTS;
  16 + vm.AuthService = AuthService;
  17 + vm.Session = Session;
  18 + vm.$log = $log;
  19 +
  20 + vm.init();
  21 + }
  22 +
  23 + AuthController.prototype.init = function() {
  24 + var vm = this;
  25 +
  26 + // init variables
  27 + vm.credentials = {};
  28 +
  29 + // attach events
  30 +
  31 + // ...
  32 + };
  33 +
  34 + AuthController.prototype.login = function(credentials) {
  35 + var vm = this;
  36 +
  37 + vm.AuthService.login(credentials).then(function(user) {
  38 + // handle view
  39 + }, function() {
  40 + // handle view
  41 + });
  42 + };
  43 +
  44 +})();
... ...
src/app/partials/auth/auth.scss 0 → 100644
... ... @@ -0,0 +1,44 @@
  1 +.btn-social {
  2 + color: #fff;
  3 + font-weight: bold;
  4 +
  5 + &:hover,
  6 + &:focus {color: #fff;}
  7 +
  8 + &.btn-facebook {
  9 + background-color: #33477a;
  10 + &:hover,
  11 + &:focus {background-color: #304373; }
  12 + &:active {background-color: #33477a; }
  13 + }
  14 + &.btn-google-plus {
  15 + background-color: #b92d25;
  16 + &:hover,
  17 + &:focus {background-color: #b12b23; }
  18 + &:active {background-color: #b92d25; }
  19 + }
  20 +}
  21 +
  22 +.glyphicon {
  23 + &.icon-white {
  24 + fill: white;
  25 + }
  26 +}
  27 +
  28 +.separator-or {
  29 + border-top: 2px solid #d8d8d8;
  30 + text-align: center;
  31 + font-weight: bold;
  32 +
  33 + &:after {
  34 + content: "ou";
  35 + position: absolute;
  36 + top: 4px;
  37 + left: 50%;
  38 + margin-left: -26px;
  39 + font-size: 30px;
  40 + line-height: 30px;
  41 + padding: 0 0.25em;
  42 + background: $gray;
  43 + }
  44 +}
... ...
src/app/partials/auth/signin.html 0 → 100644
... ... @@ -0,0 +1,38 @@
  1 +<section role="main" class="section-gray">
  2 + <div class="container">
  3 + <div class="row">
  4 + <div class="col-sm-8 col-sm-offset-2">
  5 + <h2>Identifique-se</h2>
  6 + <form name="loginForm" ng-submit="login.login(login.credentials)">
  7 + <div class="form-group">
  8 + <label for="inputUsername" class="sr-only">E-mail:</label>
  9 + <div class="input-group">
  10 + <div class="input-group-addon"><span class="glyphicon glyphicon-user"></span></div>
  11 + <input type="text" id="inputUsername" class="form-control" placeholder="E-mail" required="" autofocus="" ng-model="login.credentials.username">
  12 + </div>
  13 + </div>
  14 + <div class="form-group">
  15 + <label for="inputPassword" class="sr-only">Senha:</label>
  16 + <div class="input-group">
  17 + <div class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></div>
  18 + <input type="password" id="inputPassword" class="form-control" placeholder="Senha" required="" ng-model="login.credentials.password">
  19 + </div>
  20 + </div>
  21 + <div class="form-group">
  22 + <button class="btn btn-lg btn-primary btn-block" type="submit">Entrar</button>
  23 + </div>
  24 + </form>
  25 + </div>
  26 + </div>
  27 + <div class="row">
  28 + <div class="col-sm-8 col-sm-offset-2">
  29 + <hr class="separator-or"></hr>
  30 + </div>
  31 + </div>
  32 + <div class="row">
  33 + <div class="col-sm-8 col-sm-offset-2">
  34 + <button class="btn btn-lg btn-link btn-block" type="button" ui-sref="cadastrar">Cadastre-se</button>
  35 + </div>
  36 + </div>
  37 + </div>
  38 +</section>
... ...
src/app/partials/auth/signup.html 0 → 100644
... ... @@ -0,0 +1,54 @@
  1 +<section>
  2 + <div class="container">
  3 + <div class="row">
  4 + <div class="col-sm-12">
  5 + <h1>Cadastro</h1>
  6 + <p>Cadastre-se para fazer parte do Dialoga Brasil, interagir com as propostas e enviar as suas!</p>
  7 + </div>
  8 + </div>
  9 + </div>
  10 +</section>
  11 +<section role="main" class="section-gray">
  12 + <div class="container">
  13 + <div class="row">
  14 + <div class="col-sm-8 col-sm-offset-2">
  15 + <h2>Conecte-se por redes sociais</h2>
  16 + <div class="col-sm-6">
  17 + <button type="button" class="btn btn-lg btn-block btn-social btn-facebook">
  18 + <span class="glyphicon icon-facebook icon-white" aria-hidden="true">
  19 + <!-- Facebook -->
  20 + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 33 33" width="25" height="25"><path d="M18 32L12 32 12 16l-4 0 0-5.5 4 0 0-3.2C12 2.7 13.2 0 18.5 0l4.4 0 0 5.5 -2.8 0c-2.1 0-2.2 0.8-2.2 2.2l0 2.8 5 0 -0.6 5.5L18 16 18 32z"/></svg>
  21 +
  22 + <!-- Twitter -->
  23 + <!-- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 33 33" width="25" height="25"><path d="M32 6.1c-1.2 0.5-2.4 0.9-3.8 1 1.4-0.8 2.4-2.1 2.9-3.6 -1.3 0.8-2.7 1.3-4.2 1.6 -1.2-1.3-2.9-2.1-4.8-2.1 -3.6 0-6.6 2.9-6.6 6.6 0 0.5 0.1 1 0.2 1.5 -5.5-0.3-10.3-2.9-13.5-6.9 -0.6 1-0.9 2.1-0.9 3.3 0 2.3 1.2 4.3 2.9 5.5 -1.1 0-2.1-0.3-3-0.8 0 0 0 0.1 0 0.1 0 3.2 2.3 5.8 5.3 6.4 -0.6 0.2-1.1 0.2-1.7 0.2 -0.4 0-0.8 0-1.2-0.1 0.8 2.6 3.3 4.5 6.1 4.6 -2.2 1.8-5.1 2.8-8.2 2.8 -0.5 0-1.1 0-1.6-0.1 2.9 1.9 6.4 3 10.1 3 12.1 0 18.7-10 18.7-18.7 0-0.3 0-0.6 0-0.8C30 8.5 31.1 7.4 32 6.1z"/></svg> -->
  24 + </span>
  25 + <span class="text">
  26 + Conectar pelo Facebook
  27 + </span>
  28 + </button>
  29 + </div>
  30 + <div class="col-sm-6">
  31 + <button type="button" class="btn btn-lg btn-block btn-social btn-google-plus">
  32 + <span class="glyphicon icon-google-plus icon-white" aria-hidden="true">
  33 + <!-- Google + -->
  34 + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 33 33" width="25" height="25"><path d="M17.5 2c0 0-6.3 0-8.4 0C5.3 2 1.8 4.8 1.8 8.1c0 3.4 2.6 6.1 6.4 6.1 0.3 0 0.5 0 0.8 0 -0.2 0.5-0.4 1-0.4 1.6 0 0.9 0.5 1.7 1.1 2.3 -0.5 0-0.9 0-1.5 0C3.6 18.1 0 21.1 0 24.1c0 3 3.9 4.9 8.6 4.9 5.3 0 8.2-3 8.2-6 0-2.4-0.7-3.9-2.9-5.4 -0.8-0.5-2.2-1.8-2.2-2.6 0-0.9 0.3-1.3 1.6-2.4 1.4-1.1 2.4-2.6 2.4-4.4 0-2.1-0.9-4.2-2.7-4.8l2.7 0L17.5 2zM14.5 22.5c0.1 0.3 0.1 0.6 0.1 0.9 0 2.4-1.6 4.4-6.1 4.4 -3.2 0-5.5-2-5.5-4.5 0-2.4 2.9-4.4 6.1-4.4 0.8 0 1.4 0.1 2.1 0.3C12.9 20.4 14.2 21.1 14.5 22.5zM9.4 13.4c-2.2-0.1-4.2-2.4-4.6-5.2 -0.4-2.8 1.1-5 3.2-4.9 2.2 0.1 4.2 2.3 4.6 5.2C13 11.2 11.6 13.4 9.4 13.4zM26 8L26 2 24 2 24 8 18 8 18 10 24 10 24 16 26 16 26 10 32 10 32 8z"/></svg>
  35 + </span>
  36 + <span class="text">
  37 + Conectar pelo Google+
  38 + </span>
  39 + </button>
  40 + </div>
  41 + </div>
  42 + </div>
  43 + <div class="row">
  44 + <div class="col-sm-8 col-sm-offset-2">
  45 + <hr class="separator-or"></hr>
  46 + </div>
  47 + </div>
  48 + <div class="row">
  49 + <div class="col-sm-8 col-sm-offset-2">
  50 + <h2>Faça o cadastro abaixo</h2>
  51 + </div>
  52 + </div>
  53 + </div>
  54 +</section>
... ...
src/app/partials/header/header.html
... ... @@ -6,7 +6,7 @@
6 6 <span class="glyphicon glyphicon-adjust" aria-hidden="true"></span> Alto Contraste
7 7 </button>
8 8  
9   - <button type="button" class="btn btn-link pull-right" ui-sref="login">
  9 + <button type="button" class="btn btn-link pull-right" ui-sref="entrar">
10 10 <span class="glyphicon glyphicon-user"></span>
11 11 Entrar
12 12 </button>
... ...
src/app/partials/inicio/inicio.scss
1   -$gray: #f1f1f1;
2   -
3 1 .section-gray {
4 2 background-color: $gray;
5 3 }
... ...
src/app/partials/login/login.controller.js
... ... @@ -1,44 +0,0 @@
1   -(function() {
2   - 'use strict';
3   -
4   - angular
5   - .module('dialoga')
6   - .controller('LoginController', LoginController);
7   -
8   - /** @ngInject */
9   - function LoginController($rootScope, AUTH_EVENTS, AuthService, Session, $log) {
10   - $log.debug('LoginController');
11   -
12   - var vm = this;
13   -
14   - vm.$rootScope = $rootScope;
15   - vm.AUTH_EVENTS = AUTH_EVENTS;
16   - vm.AuthService = AuthService;
17   - vm.Session = Session;
18   - vm.$log = $log;
19   -
20   - vm.init();
21   - }
22   -
23   - LoginController.prototype.init = function() {
24   - var vm = this;
25   -
26   - // init variables
27   - vm.credentials = {};
28   -
29   - // attach events
30   -
31   - // ...
32   - };
33   -
34   - LoginController.prototype.login = function(credentials) {
35   - var vm = this;
36   -
37   - vm.AuthService.login(credentials).then(function(user) {
38   - // handle view
39   - }, function() {
40   - // handle view
41   - });
42   - };
43   -
44   -})();
src/app/partials/login/login.html
... ... @@ -1,27 +0,0 @@
1   -<section role="main" class="section-gray">
2   - <div class="container">
3   - <div class="row">
4   - <div class="col-sm-8 col-sm-offset-2">
5   - <form name="loginForm" ng-submit="login.login(login.credentials)">
6   - <div class="form-group">
7   - <label for="inputUsername" class="sr-only">E-mail:</label>
8   - <div class="input-group">
9   - <div class="input-group-addon"><span class="glyphicon glyphicon-user"></span></div>
10   - <input type="text" id="inputUsername" class="form-control" placeholder="E-mail" required="" autofocus="" ng-model="login.credentials.username">
11   - </div>
12   - </div>
13   - <div class="form-group">
14   - <label for="inputPassword" class="sr-only">Senha:</label>
15   - <div class="input-group">
16   - <div class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></div>
17   - <input type="password" id="inputPassword" class="form-control" placeholder="Senha" required="" ng-model="login.credentials.password">
18   - </div>
19   - </div>
20   - <div class="form-group">
21   - <button class="btn btn-lg btn-primary btn-block" type="submit">Entrar</button>
22   - </div>
23   - </form>
24   - </div>
25   - </div>
26   - </div>
27   -</section>
src/app/partials/login/login.scss
... ... @@ -1,44 +0,0 @@
1   -.btn-social {
2   - color: #fff;
3   - font-weight: bold;
4   -
5   - &:hover,
6   - &:focus {color: #fff;}
7   -
8   - &.btn-facebook {
9   - background-color: #33477a;
10   - &:hover,
11   - &:focus {background-color: #304373; }
12   - &:active {background-color: #33477a; }
13   - }
14   - &.btn-google-plus {
15   - background-color: #b92d25;
16   - &:hover,
17   - &:focus {background-color: #b12b23; }
18   - &:active {background-color: #b92d25; }
19   - }
20   -}
21   -
22   -.glyphicon {
23   - &.icon-white {
24   - fill: white;
25   - }
26   -}
27   -
28   -.separator-or {
29   - border-top: 2px solid #d8d8d8;
30   - text-align: center;
31   - font-weight: bold;
32   -
33   - &:after {
34   - content: "ou";
35   - position: absolute;
36   - top: 4px;
37   - left: 50%;
38   - margin-left: -26px;
39   - font-size: 30px;
40   - line-height: 30px;
41   - padding: 0 0.25em;
42   - background: $gray;
43   - }
44   -}
src/app/partials/login/signup.html
... ... @@ -1,54 +0,0 @@
1   -<section>
2   - <div class="container">
3   - <div class="row">
4   - <div class="col-sm-12">
5   - <h1>Cadastro</h1>
6   - <p>Cadastre-se para fazer parte do Dialoga Brasil, interagir com as propostas e enviar as suas!</p>
7   - </div>
8   - </div>
9   - </div>
10   -</section>
11   -<section role="main" class="section-gray">
12   - <div class="container">
13   - <div class="row">
14   - <div class="col-sm-8 col-sm-offset-2">
15   - <h2>Conecte-se por redes sociais</h2>
16   - <div class="col-sm-6">
17   - <button type="button" class="btn btn-lg btn-block btn-social btn-facebook">
18   - <span class="glyphicon icon-facebook icon-white" aria-hidden="true">
19   - <!-- Facebook -->
20   - <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 33 33" width="25" height="25"><path d="M18 32L12 32 12 16l-4 0 0-5.5 4 0 0-3.2C12 2.7 13.2 0 18.5 0l4.4 0 0 5.5 -2.8 0c-2.1 0-2.2 0.8-2.2 2.2l0 2.8 5 0 -0.6 5.5L18 16 18 32z"/></svg>
21   -
22   - <!-- Twitter -->
23   - <!-- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 33 33" width="25" height="25"><path d="M32 6.1c-1.2 0.5-2.4 0.9-3.8 1 1.4-0.8 2.4-2.1 2.9-3.6 -1.3 0.8-2.7 1.3-4.2 1.6 -1.2-1.3-2.9-2.1-4.8-2.1 -3.6 0-6.6 2.9-6.6 6.6 0 0.5 0.1 1 0.2 1.5 -5.5-0.3-10.3-2.9-13.5-6.9 -0.6 1-0.9 2.1-0.9 3.3 0 2.3 1.2 4.3 2.9 5.5 -1.1 0-2.1-0.3-3-0.8 0 0 0 0.1 0 0.1 0 3.2 2.3 5.8 5.3 6.4 -0.6 0.2-1.1 0.2-1.7 0.2 -0.4 0-0.8 0-1.2-0.1 0.8 2.6 3.3 4.5 6.1 4.6 -2.2 1.8-5.1 2.8-8.2 2.8 -0.5 0-1.1 0-1.6-0.1 2.9 1.9 6.4 3 10.1 3 12.1 0 18.7-10 18.7-18.7 0-0.3 0-0.6 0-0.8C30 8.5 31.1 7.4 32 6.1z"/></svg> -->
24   - </span>
25   - <span class="text">
26   - Conectar pelo Facebook
27   - </span>
28   - </button>
29   - </div>
30   - <div class="col-sm-6">
31   - <button type="button" class="btn btn-lg btn-block btn-social btn-google-plus">
32   - <span class="glyphicon icon-google-plus icon-white" aria-hidden="true">
33   - <!-- Google + -->
34   - <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 33 33" width="25" height="25"><path d="M17.5 2c0 0-6.3 0-8.4 0C5.3 2 1.8 4.8 1.8 8.1c0 3.4 2.6 6.1 6.4 6.1 0.3 0 0.5 0 0.8 0 -0.2 0.5-0.4 1-0.4 1.6 0 0.9 0.5 1.7 1.1 2.3 -0.5 0-0.9 0-1.5 0C3.6 18.1 0 21.1 0 24.1c0 3 3.9 4.9 8.6 4.9 5.3 0 8.2-3 8.2-6 0-2.4-0.7-3.9-2.9-5.4 -0.8-0.5-2.2-1.8-2.2-2.6 0-0.9 0.3-1.3 1.6-2.4 1.4-1.1 2.4-2.6 2.4-4.4 0-2.1-0.9-4.2-2.7-4.8l2.7 0L17.5 2zM14.5 22.5c0.1 0.3 0.1 0.6 0.1 0.9 0 2.4-1.6 4.4-6.1 4.4 -3.2 0-5.5-2-5.5-4.5 0-2.4 2.9-4.4 6.1-4.4 0.8 0 1.4 0.1 2.1 0.3C12.9 20.4 14.2 21.1 14.5 22.5zM9.4 13.4c-2.2-0.1-4.2-2.4-4.6-5.2 -0.4-2.8 1.1-5 3.2-4.9 2.2 0.1 4.2 2.3 4.6 5.2C13 11.2 11.6 13.4 9.4 13.4zM26 8L26 2 24 2 24 8 18 8 18 10 24 10 24 16 26 16 26 10 32 10 32 8z"/></svg>
35   - </span>
36   - <span class="text">
37   - Conectar pelo Google+
38   - </span>
39   - </button>
40   - </div>
41   - </div>
42   - </div>
43   - <div class="row">
44   - <div class="col-sm-8 col-sm-offset-2">
45   - <hr class="separator-or"></hr>
46   - </div>
47   - </div>
48   - <div class="row">
49   - <div class="col-sm-8 col-sm-offset-2">
50   - <h2>Faça o cadastro abaixo</h2>
51   - </div>
52   - </div>
53   - </div>
54   -</section>