Commit 813cab6f9466430969d8c7be1052bdc03d06feda
1 parent
982b1d0428
Exists in
master
and in
1 other branch
Added reset request controller, but no html for it yet. Logout page delay not working
Showing 7 changed files with 70 additions and 18 deletions Inline Diff
config.js
View file @
813cab6
angular.module('flashy', [ | 1 | 1 | angular.module('flashy', [ | |
'flashy.LogoutController', | 2 | 2 | 'flashy.LogoutController', | |
'flashy.LoginController', | 3 | 3 | 'flashy.LoginController', | |
'flashy.HomeController', | 4 | 4 | 'flashy.HomeController', | |
'flashy.FeedController', | 5 | 5 | 'flashy.FeedController', | |
'flashy.DeckController', | 6 | 6 | 'flashy.DeckController', | |
'ngCookies']). | 7 | 7 | 'ngCookies']). | |
config(['$stateProvider', '$urlRouterProvider', '$httpProvider', | 8 | 8 | config(['$stateProvider', '$urlRouterProvider', '$httpProvider', | |
'$locationProvider', | 9 | 9 | '$locationProvider', | |
function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) { | 10 | 10 | function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) { | |
'use strict'; | 11 | 11 | 'use strict'; | |
$httpProvider.defaults.withCredentials = true; | 12 | 12 | $httpProvider.defaults.withCredentials = true; | |
$httpProvider.defaults.xsrfCookieName = 'csrftoken'; | 13 | 13 | $httpProvider.defaults.xsrfCookieName = 'csrftoken'; | |
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | 14 | 14 | $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | |
$locationProvider.html5Mode(true); | 15 | 15 | $locationProvider.html5Mode(true); | |
$urlRouterProvider.otherwise('/home'); | 16 | 16 | $urlRouterProvider.otherwise('/home'); | |
$stateProvider. | 17 | 17 | $stateProvider. | |
state('home', { | 18 | 18 | state('home', { | |
url: '/home', | 19 | 19 | url: '/home', | |
templateUrl: 'home.html', | 20 | 20 | templateUrl: 'home.html', | |
controller: 'HomeController' | 21 | 21 | controller: 'HomeController' | |
}). | 22 | 22 | }). | |
state('login', { | 23 | 23 | state('login', { | |
url: '/login', | 24 | 24 | url: '/login', | |
templateUrl: 'templates/login_form.html', | 25 | 25 | templateUrl: 'templates/login_form.html', | |
controller: 'LoginController' | 26 | 26 | controller: 'LoginController' | |
}). | 27 | 27 | }). | |
state('logout', { | 28 | 28 | state('logout', { | |
url: '/logout', | 29 | 29 | url: '/logout', | |
templateUrl: 'templates/logout.html', | 30 | 30 | templateUrl: 'templates/logout.html', | |
controller: 'LogoutController' | 31 | 31 | controller: 'LogoutController' | |
}). | 32 | 32 | }). | |
state('dashboard', { | 33 | 33 | state('dashboard', { | |
url: '/dashboard', | 34 | 34 | url: '/dashboard', | |
templateUrl: 'templates/dashboard.html', | 35 | 35 | templateUrl: 'templates/dashboard.html', | |
controller: 'DashboardController' | 36 | 36 | controller: 'DashboardController' | |
}). | 37 | 37 | }). | |
state('feed', { | 38 | 38 | state('feed', { | |
url: '/feed', | 39 | 39 | url: '/feed', | |
templateUrl: 'templates/feed.html', | 40 | 40 | templateUrl: 'templates/feed.html', | |
controller: 'FeedController' | 41 | 41 | controller: 'FeedController' | |
}). | 42 | 42 | }). | |
state('deck', { | 43 | 43 | state('deck', { | |
url: '/deck', | 44 | 44 | url: '/deck', | |
templateUrl: 'templates/deck.html', | 45 | 45 | templateUrl: 'templates/deck.html', | |
controller: 'DeckController' | 46 | 46 | controller: 'DeckController' | |
}); | 47 | 47 | }). | |
48 | state('requestpasswordreset', { | |||
49 | url: '/requestpasswordreset', | |||
50 | templateUrl: 'templates/requestpasswordreset.html', | |||
51 | controller: 'RequestResetController' | |||
52 | }); | |||
48 | 53 | |||
}]); | 49 | 54 | }]); |
flashy.css
View file @
813cab6
#loginform input { | 1 | 1 | #loginform input { | |
margin: 10px; | 2 | 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; | |||
} | 3 | 8 | } | |
4 | 9 | |||
#loginform { | 5 | 10 | #loginform { | |
max-width: 400px; | 6 | 11 | width: 100%; | |
max-height: 300px; | 7 | 12 | max-height: 300px; | |
} | 8 | 13 | } | |
9 | 14 | |||
10 | 15 | #sidebar { | ||
#sidebar{ | 11 | |||
position:absolute; | 12 | 16 | position:absolute; | |
top:100px; | 13 | 17 | top:100px; | |
left:0px; | 14 | 18 | left:0px; | |
} | 15 | 19 | } | |
16 | 20 | |||
.container{ | 17 | 21 | .diclaimer { | |
22 | color:#00AFD8; | |||
23 | } | |||
24 | ||||
25 | .container { | |||
width: 500px; | 18 | 26 | width: 500px; | |
} | 19 | 27 | } |
scripts/LoginController.js
View file @
813cab6
angular.module('flashy.LoginController', ['ui.router']). | 1 | 1 | angular.module('flashy.LoginController', ['ui.router']). | |
2 | 2 | |||
controller('LoginController', ['$scope', '$state', '$http', | 3 | 3 | controller('LoginController', ['$scope', '$state', '$http', | |
function($scope, $state, $http) { | 4 | 4 | function($scope, $state, $http) { | |
'use strict'; | 5 | 5 | 'use strict'; | |
$scope.emailError = false | 6 | 6 | $scope.emailError = false; | |
$scope.loginError = false | 7 | 7 | $scope.loginError = false; | |
$scope.login = function(email, password) { | 8 | 8 | $scope.login = function(email, password) { | |
$http.post('/api/login', JSON.stringify({ | 9 | 9 | $http.post('/api/login', JSON.stringify({ | |
'email': email, | 10 | 10 | 'email': email, | |
'password': password | 11 | 11 | 'password': password | |
})) | 12 | 12 | })) | |
.success(function(data) { | 13 | 13 | .success(function(data) { | |
$state.go('feed'); | 14 | 14 | $state.go('feed'); | |
console.log(data); | 15 | 15 | console.log(data); | |
}) | 16 | 16 | }) | |
.error(function(data, status, header, config) { | 17 | 17 | .error(function(data, status, header, config) { | |
if(data.detail) { // assume 'invalid email or pass' | 18 | 18 | if(data.detail) { // assume 'invalid email or pass' | |
$scope.emailError = true; | 19 | 19 | $scope.emailError = true; | |
} | 20 | 20 | } | |
console.log(data) | 21 | 21 | console.log(data) | |
}); | 22 | 22 | }); | |
}; | 23 | 23 | }; | |
$scope.signUp = function(email, password) { | 24 | 24 | $scope.signUp = function(email, password) { | |
$http.post('/api/register', JSON.stringify({ | 25 | 25 | $http.post('/api/register', JSON.stringify({ | |
'email': email, | 26 | 26 | 'email': email, | |
'password': password | 27 | 27 | 'password': password | |
})) | 28 | 28 | })) | |
.success(function(data) { | 29 | 29 | .success(function(data) { | |
$state.go('feed'); | 30 | 30 | $state.go('feed'); | |
console.log(data); | 31 | 31 | console.log(data); | |
}) | 32 | 32 | }) | |
.error(function(data, status, headers, config) { | 33 | 33 | .error(function(data, status, headers, config) { | |
if(data.email) { // assume 'email not unique' error | 34 | 34 | if(data.email) { // assume 'email not unique' error | |
$scope.emailError = true; | 35 | 35 | $scope.emailError = true; | |
email.forcus(); | 36 | 36 | email.forcus(); | |
} | 37 | 37 | } | |
console.log(data); | 38 | 38 | console.log(data); | |
}); | 39 | 39 | }); | |
}; | 40 | 40 | }; | |
41 | $scope.triggerPasswordReset = function() { | |||
42 | $state.go('requestpasswordreset'); | |||
43 | }; | |||
} | 41 | 44 | } | |
]); | 42 | 45 | ]); | |
43 | 46 |
scripts/LogoutController.js
View file @
813cab6
angular.module('flashy.LogoutController', ['ui.router']). | 1 | 1 | angular.module('flashy.LogoutController', ['ui.router']). | |
2 | 2 | |||
controller('LogoutController', ['$scope', '$state', '$http', function($scope, $state, $http) { | 3 | 3 | controller('LogoutController', ['$scope', '$state', '$timeout', | |
$http.post('/api/logout').success(function() { | 4 | 4 | function($scope, $state, $timeout) { | |
$state.go('home'); | 5 | 5 | $timeout(function($state) { | |
}); | 6 | 6 | $state.go('home'); | |
}]); | 7 | 7 | }, 1000); | |
8 | } | |||
9 | ]); | |||
8 | 10 | |||
scripts/RequestResetController.js
View file @
813cab6
File was created | 1 | angular.module('flashy.RequestResetController', ['ui.router']). | ||
2 | ||||
3 | controller('RequestResetController', ['$scope', '$state', 'http', | |||
4 | function($scope, $state, $http) { | |||
5 | 'use strict'; | |||
6 | $scope.success = false; | |||
7 | $scope.alert = false; | |||
8 | $scope.resetPass = function(email) { | |||
9 | $http.post('/api/request_password_reset', JSON.stringify({ | |||
10 | 'email': email | |||
11 | })) | |||
12 | .success(function(data) { | |||
13 | $scope.success = true; | |||
14 | console.log(data); | |||
15 | }) | |||
16 | .error(function(data, status, header, config) { | |||
17 | if(data.email) { | |||
18 | $scope.success = false; | |||
19 | $scope.alert = true; | |||
20 | } | |||
21 | console.log(data) | |||
22 | }); | |||
23 | } | |||
24 | } |
templates/login_form.html
View file @
813cab6
<div class="container"> | 1 | 1 | <div class="container"> | |
<form id="loginform"> | 2 | 2 | <form id="loginform"> | |
<div class="container"> | 3 | 3 | <div class="container"> | |
<h1 class="text-success heading">FLASHY</h1> | 4 | 4 | <h1 class="text-success heading">FLASHY</h1> | |
<blockquote class="pull-left" id="loginquote"> | 5 | 5 | <blockquote class="pull-left" id="loginquote"> | |
<p>The System shall enlighten.<br>The User shall be enlightened.</p> | 6 | 6 | <p>The System shall enlighten.<br>The User shall be enlightened.</p> | |
<small>SWAG</small> | 7 | 7 | <small>SWAG</small> | |
</blockquote> | 8 | 8 | </blockquote> | |
</div> | 9 | 9 | </div> | |
10 | 10 | |||
<div class="container"> | 11 | 11 | <div class="container"> | |
<!-- REGISTRATION TABS --> | 12 | 12 | <!-- REGISTRATION TABS --> | |
<div class="tabbable"> | 13 | 13 | <div class="tabbable"> | |
<ul class="nav nav-pills nav-justified"> | 14 | 14 | <ul class="nav nav-pills nav-justified"> | |
<li role="presentation" class="active"><a href="#tab1" data-toggle="tab">SIGN UP</a></li> | 15 | 15 | <li role="presentation" class="active"><a href="#tab1" data-toggle="tab">SIGN UP</a></li> | |
<li role="presentation"><a href="#tab2" data-toggle="tab">LOGIN</a></li> | 16 | 16 | <li role="presentation"><a href="#tab2" data-toggle="tab">LOGIN</a></li> | |
</ul> | 17 | 17 | </ul> | |
</div> | 18 | 18 | </div> | |
19 | 19 | |||
<!-- REGISTRATION PANES --> | 20 | 20 | <!-- REGISTRATION PANES --> | |
<div class="tab-content" id="registration_forms"> | 21 | 21 | <div class="tab-content" id="registration_forms"> | |
<!-- SIGN UP FORM --> | 22 | 22 | <!-- SIGN UP FORM --> | |
<div class="tab-pane active myform" id="tab1"> | 23 | 23 | <div class="tab-pane active myform" id="tab1"> | |
<form> | 24 | 24 | <form class="login_input_form"> | |
<div class="form-group"> | 25 | 25 | <div class="form-group"> | |
<input name="email" type="email" class="form-control" ng-model="signUpEmail" placeholder="Email" required /> | 26 | 26 | <input name="email" type="email" class="form-control" ng-model="signUpEmail" placeholder="Email" required /> | |
</div> | 27 | 27 | </div> | |
<div class="check-element animate-show" role="alert" ng-show="signUpEmail.$dirty && emailError"> | 28 | 28 | <div class="check-element animate-show" role="alert" ng-show="signUpEmail.$dirty && emailError"> | |
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | 29 | 29 | <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | |
<span style="color:#8E2323">{{signUpEmail}} already registered!</span> | 30 | 30 | <span style="color:#8E2323">{{signUpEmail}} already registered!</span> | |
</div> | 31 | 31 | </div> | |
<div class="form-group"> | 32 | 32 | <div class="form-group"> | |
<input name="password" type="password" class="form-control" ng-model="signUpPassword" placeholder="Password" required /> | 33 | 33 | <input name="password" type="password" class="form-control" ng-model="signUpPassword" placeholder="Password" required /> | |
</div> | 34 | 34 | </div> | |
<input type="submit" class="btn btn-primary btn-block" ng-click="signUp(signUpEmail, signUpPassword)" value="Sign up" /> | 35 | 35 | <input type="submit" class="btn btn-primary btn-block" ng-click="signUp(signUpEmail, signUpPassword)" value="Sign up" /> | |
</form> | 36 | 36 | </form> | |
</div> | 37 | 37 | </div> | |
38 | 38 | |||
<!-- LOGIN FORM --> | 39 | 39 | <!-- LOGIN FORM --> | |
<div class="tab-pane myform" id="tab2"> | 40 | 40 | <div class="tab-pane myform" id="tab2"> | |
<form> | 41 | 41 | <form class="login_input_form"> | |
<div class="check-element animate-show" role="alert" ng-show="loginEmail.$dirty && loginError" /> | 42 | 42 | <div class="check-element animate-show" role="alert" ng-show="loginEmail.$dirty && loginError"> | |
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | 43 | 43 | <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | |
<span style="color:#8E2323">Invalid username or password!</span> | 44 | 44 | <span style="color:#8E2323">Invalid username or password!</span> | |
</div> | 45 | 45 | </div> | |
<div class="form-group"> | 46 | 46 | <div class="form-group"> | |
<input type="email" class="form-control" ng-model="loginEmail" placeholder="Email" /> | 47 | 47 | <input type="email" class="form-control" ng-model="loginEmail" placeholder="Email" value="fe" /> | |
</div> | 48 | 48 | </div> | |
<div class="form-group"> | 49 | 49 | <div class="form-group"> | |
<input type="password" class="form-control" ng-model="loginPassword" placeholder="Password" /> | 50 | 50 | <input type="password" class="form-control" ng-model="loginPassword" placeholder="Password" /> | |
</div> | 51 | 51 | </div> | |
<input type="submit" class="btn btn-primary btn-block" ng-click="login(loginEmail, loginPassword)" value="Login" /> | 52 | 52 | <input type="submit" class="btn btn-primary btn-block" ng-click="login(loginEmail, loginPassword)" value="Login" /> | |
</form> | 53 | 53 | </form> | |
</div> | 54 | 54 | </div> | |
</div> | 55 | 55 | </div> | |
56 | ||||
57 | <!-- FORGOT PASS --> | |||
58 | <div class="disclaimer"> | |||
59 | <a class="trigger-password-reset" ng-click="triggerPasswordReset" href="#">I forgot my password</a> | |||
60 | </div> | |||
</div> | 56 | 61 | </div> | |
57 | 62 | |||
58 | 63 | |||
59 | 64 | |||
60 | 65 | |||
<!--<div> | 61 | 66 | <!--<div> | |
<input type="email" class="form-control" ng-model="loginEmail" placeholder="Email"/> | 62 | 67 | <input type="email" class="form-control" ng-model="loginEmail" placeholder="Email"/> | |
</div> | 63 | 68 | </div> | |
<div class="form-group"> | 64 | 69 | <div class="form-group"> | |
<input type="password" class="form-control" ng-model="loginPassword" placeholder="Password"/> | 65 | 70 | <input type="password" class="form-control" ng-model="loginPassword" placeholder="Password"/> | |
</div> | 66 | 71 | </div> | |
<input type="submit" class="btn btn-primary" ng-click="login(loginEmail, loginPassword)" value="LOGIN"/> | 67 | 72 | <input type="submit" class="btn btn-primary" ng-click="login(loginEmail, loginPassword)" value="LOGIN"/> | |
<input type="submit" class="btn btn-primary" ng-click="register(loginEmail, loginPassword)" value="REGISTER"/> | 68 | 73 | <input type="submit" class="btn btn-primary" ng-click="register(loginEmail, loginPassword)" value="REGISTER"/> | |
</form>--> | 69 | 74 | --> |
templates/logout.html
View file @
813cab6
File was created | 1 | <div class="container"> | ||
2 | <h3 class="text-success heading">You have successfully logged out.</h3> | |||
3 | </div> |