Commit 4fc1728b4a1820913b9958eb0417e32d698da2d1

Authored by Tetranoir
1 parent 84de792c36

added requestpasswordreset, changed name of login_form->login

Showing 7 changed files with 163 additions and 34 deletions Side-by-side Diff

... ... @@ -4,6 +4,7 @@
4 4 'flashy.HomeController',
5 5 'flashy.FeedController',
6 6 'flashy.DeckController',
  7 + 'flashy.RequestResetController',
7 8 'ngCookies']).
8 9 config(['$stateProvider', '$urlRouterProvider', '$httpProvider',
9 10 '$locationProvider',
... ... @@ -22,7 +23,7 @@
22 23 }).
23 24 state('login', {
24 25 url: '/login',
25   - templateUrl: 'templates/login_form.html',
  26 + templateUrl: 'templates/login.html',
26 27 controller: 'LoginController'
27 28 }).
28 29 state('logout', {
1 1 #loginform input {
2   - margin-top: 5px;
3   - border: 0px none;
4   - font: 16px/1.4 "Helvetica Neue","HelveticaNeue",Helvetica,Arial;
5   - padding: 11px 10px 11px 13px;
6   - width: 100%;
7   - box-sizing: border-box;
  2 +
8 3 }
9 4  
10   -#loginform {
11   - width: 100%;
12   - max-height: 300px;
13   -}
14 5  
15 6 #sidebar {
16 7 position:absolute;
17 8  
... ... @@ -22,7 +13,34 @@
22 13 color:#00AFD8;
23 14 }
24 15  
  16 +.form-section {
  17 + width: 330px;
  18 + top: 50%;
  19 + position: relative;
  20 +}
  21 +
  22 +.form-inputs {
  23 + margin-top: 0px;
  24 + border: 0px none;
  25 + font: 16px/1.4 "Helvetica Neue","HelveticaNeue",Helvetica,Arial;
  26 + padding: 5px 10px 11px 13px;
  27 + width: 100%;
  28 + box-sizing: border-box;
  29 +}
  30 +
  31 +.form-buttons {
  32 + margin-top: 10px;
  33 + width: 100%;
  34 + font-size: 16px;
  35 +}
  36 +
  37 +.form-buttons .last-button {
  38 + float: right;
  39 +}
  40 +
25 41 .container {
26   - width: 500px;
  42 + position: relative;
  43 + width: 400px;
  44 + height: 80px;
27 45 }
... ... @@ -27,6 +27,7 @@
27 27 <script src="scripts/LoginController.js"></script>
28 28 <script src="scripts/LogoutController.js"></script>
29 29 <script src="scripts/DeckController.js"></script>
  30 +<script src="scripts/RequestResetController.js"></script>
30 31  
31 32  
32 33  
scripts/LoginController.js View file @ 4fc1728
... ... @@ -3,38 +3,41 @@
3 3 controller('LoginController', ['$scope', '$state', '$http',
4 4 function($scope, $state, $http) {
5 5 'use strict';
6   - $scope.varvar = false
7   - $scope.emailError = false;
  6 + $scope.uniqueError = false;
8 7 $scope.loginError = false;
9 8 $scope.login = function(email, password) {
10 9 $http.post('/api/login', JSON.stringify({
11 10 'email': email,
12 11 'password': password
13   - }))
14   - .success(function(data) {
  12 + })).
  13 + success(function(data) {
15 14 $state.go('feed');
16 15 console.log(data);
17   - })
18   - .error(function(data, status, header, config) {
  16 + }).
  17 + error(function(data, status, header, config) {
19 18 if(data.detail) { // assume 'invalid email or pass'
20   - $scope.emailError = true;
  19 + $scope.loginError = true;
21 20 }
22   - console.log(data)
  21 + console.log(data);
23 22 });
24 23 };
25 24 $scope.signUp = function(email, password) {
26 25 $http.post('/api/register', JSON.stringify({
27 26 'email': email,
28 27 'password': password
29   - }))
30   - .success(function(data) {
  28 + })).
  29 + success(function(data) {
31 30 $state.go('feed');
32 31 console.log(data);
33   - })
34   - .error(function(data, status, headers, config) {
35   - if(data.email) { // assume 'email not unique' error
36   - $scope.emailError = true;
37   - email.forcus();
  32 + }).
  33 + error(function(data, status, headers, config) {
  34 + console.log(data.email);
  35 + if(data.email == "This field is required.") {
  36 + $scope.invalid = true;
  37 + $scope.uniqueError = false;
  38 + } else if(data.email) { // assume 'email not unique' error
  39 + $scope.uniqueError = true;
  40 + $scope.invalid = false;
38 41 }
39 42 console.log(data);
40 43 });
scripts/RequestResetController.js View file @ 4fc1728
1   -angular.module('flashy.RequestResetController', ['ui.router']).
  1 +angular.module('flashy.RequestResetController', ['ui.router'])
2 2  
3   -controller('RequestResetController', ['$scope', '$state', 'http',
  3 +.controller('RequestResetController', ['$scope', '$state', '$http',
4 4 function($scope, $state, $http) {
5 5 'use strict';
6 6 $scope.success = false;
7   - $scope.alert = false;
  7 + $scope.invalid = false;
8 8 $scope.resetPass = function(email) {
9 9 $http.post('/api/request_password_reset', JSON.stringify({
10 10 'email': email
11 11 }))
12 12 .success(function(data) {
13 13 $scope.success = true;
  14 + $state.go('passwordreset');
14 15 console.log(data);
15 16 })
16 17 .error(function(data, status, header, config) {
17 18 if(data.email) {
18   - $scope.success = false;
19   - $scope.alert = true;
  19 + $scope.invalid = true;
20 20 }
21   - console.log(data)
  21 + console.log(data);
22 22 });
23   - }
  23 + };
  24 + $scope.cancel = function() {
  25 + $state.go('home');
  26 + };
24 27 }
25 28 ]);
templates/login.html View file @ 4fc1728
  1 +<div class="content">
  2 + <form id="loginform">
  3 + <div class="container">
  4 + <h1 class="text-success heading">FLASHY</h1>
  5 + <blockquote class="pull-left" id="loginquote">
  6 + <p>The System shall enlighten.<br>The User shall be enlightened.</p>
  7 + <small>SWAG</small>
  8 + </blockquote>
  9 + </div>
  10 +
  11 + <div class="form-section">
  12 + <!-- REGISTRATION TABS -->
  13 + <div class="tabbable">
  14 + <ul class="nav nav-pills nav-justified">
  15 + <li role="presentation" class="active"><a href="#tab1" data-toggle="tab">SIGN UP</a></li>
  16 + <li role="presentation"><a href="#tab2" data-toggle="tab">LOGIN</a></li>
  17 + </ul>
  18 + </div>
  19 +
  20 + <!-- REGISTRATION PANES -->
  21 + <div class="tab-content" id="registration_forms">
  22 + <!-- LOGIN FORM -->
  23 + <div class="tab-pane myform" id="tab2">
  24 + <div class="form-inputs" name="login_form_input">
  25 + <div class="check-element animate-show" role="alert" ng-show="loginError">
  26 + <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
  27 + <span style="color:#8E2323">Invalid username or password!!</span>
  28 + </div>
  29 + <div class="form-group">
  30 + <input type="email" class="form-control" ng-model="loginEmail" placeholder="Email" required />
  31 + </div>
  32 + <div class="form-group">
  33 + <input type="password" class="form-control" ng-model="loginPassword" placeholder="Password" required />
  34 + </div>
  35 + <input type="submit" class="btn btn-primary btn-block" ng-click="login(loginEmail, loginPassword)" value="Login!" />
  36 + </div>
  37 + </div>
  38 +
  39 + <!-- SIGN UP FORM -->
  40 + <div class="tab-pane active myform" id="tab1">
  41 + <div class="form-inputs" name="register_form_input">
  42 + <div class="check-element animate-show" role="alert" ng-show="uniqueError">
  43 + <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
  44 + <span style="color:#8E2323">Email already registered!</span>
  45 + </div>
  46 + <div class="form-group">
  47 + <input name="email" type="email" class="form-control" ng-model="loginEmail" placeholder="Email" required />
  48 + </div>
  49 + <div class="form-group">
  50 + <input name="password" type="password" class="form-control" ng-model="signUpPassword" placeholder="Password" required />
  51 + </div>
  52 + <input type="submit" class="btn btn-primary btn-block" ng-click="signUp(loginEmail, signUpPassword)" value="Sign up!" />
  53 + </div>
  54 + </div>
  55 + </div>
  56 +
  57 + <!-- FORGOT PASS -->
  58 + <div class="disclaimer">
  59 + <a class="trigger-password-reset" ng-click="triggerPasswordReset()" href="#">forget ur password???</a>
  60 + </div>
  61 + </div>
  62 +
  63 +
  64 +
  65 +
  66 + <!--<div>
  67 + <input type="email" class="form-control" ng-model="loginEmail" placeholder="Email"/>
  68 + </div>
  69 + <div class="form-group">
  70 + <input type="password" class="form-control" ng-model="loginPassword" placeholder="Password"/>
  71 + </div>
  72 + <input type="submit" class="btn btn-primary" ng-click="login(loginEmail, loginPassword)" value="LOGIN"/>
  73 + <input type="submit" class="btn btn-primary" ng-click="register(loginEmail, loginPassword)" value="REGISTER"/>
  74 + -->
  75 + </form>
  76 +</div>
templates/requestpasswordreset.html View file @ 4fc1728
  1 +<div class="content">
  2 + <div class="container">
  3 + <h1 class="text-muted">Reset Password</h1>
  4 + </div>
  5 + <div name="passreset" class="form-section">
  6 + <form class="form-inputs" name="passreset_form">
  7 + <div class="check-element animate-show" role="alert" ng-show="invalid">
  8 + <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
  9 + <span style="color:#8E2323">Enter a valid email!</span>
  10 + </div>
  11 + <div class="form-group">
  12 + <input type="email" class="form-control" ng-model="user_email" placeholder="Email" required />
  13 + </div>
  14 + <div class="form-buttons">
  15 + <div class="btn-group">
  16 + <button type="button" class="btn btn-default" ng-click="cancel()"><strong>Cancel</strong></button>
  17 + </div>
  18 + <div class="last-button">
  19 + <div class="btn-group">
  20 + <button type="button" class="btn btn-danger" ng-click="resetPass(user_email)"><strong>Reset Password</strong></button>
  21 + </div>
  22 + </div>
  23 + </div>
  24 + </form>
  25 + </div>
  26 +</div>