Commit 84de792c36bad53138f57e16b25b2f85191035ec
1 parent
813cab6f94
Exists in
master
and in
1 other branch
testing... nothing worth noting
Showing 2 changed files with 13 additions and 6 deletions Inline Diff
scripts/LoginController.js
View file @
84de792
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'; | |
6 | $scope.varvar = false | |||
$scope.emailError = false; | 6 | 7 | $scope.emailError = false; | |
$scope.loginError = false; | 7 | 8 | $scope.loginError = false; | |
$scope.login = function(email, password) { | 8 | 9 | $scope.login = function(email, password) { | |
$http.post('/api/login', JSON.stringify({ | 9 | 10 | $http.post('/api/login', JSON.stringify({ | |
'email': email, | 10 | 11 | 'email': email, | |
'password': password | 11 | 12 | 'password': password | |
})) | 12 | 13 | })) | |
.success(function(data) { | 13 | 14 | .success(function(data) { | |
$state.go('feed'); | 14 | 15 | $state.go('feed'); | |
console.log(data); | 15 | 16 | console.log(data); | |
}) | 16 | 17 | }) | |
.error(function(data, status, header, config) { | 17 | 18 | .error(function(data, status, header, config) { | |
if(data.detail) { // assume 'invalid email or pass' | 18 | 19 | if(data.detail) { // assume 'invalid email or pass' | |
$scope.emailError = true; | 19 | 20 | $scope.emailError = true; | |
} | 20 | 21 | } | |
console.log(data) | 21 | 22 | console.log(data) | |
}); | 22 | 23 | }); | |
}; | 23 | 24 | }; | |
$scope.signUp = function(email, password) { | 24 | 25 | $scope.signUp = function(email, password) { | |
$http.post('/api/register', JSON.stringify({ | 25 | 26 | $http.post('/api/register', JSON.stringify({ | |
'email': email, | 26 | 27 | 'email': email, | |
'password': password | 27 | 28 | 'password': password | |
})) | 28 | 29 | })) | |
.success(function(data) { | 29 | 30 | .success(function(data) { | |
$state.go('feed'); | 30 | 31 | $state.go('feed'); | |
console.log(data); | 31 | 32 | console.log(data); | |
}) | 32 | 33 | }) | |
.error(function(data, status, headers, config) { | 33 | 34 | .error(function(data, status, headers, config) { | |
if(data.email) { // assume 'email not unique' error | 34 | 35 | if(data.email) { // assume 'email not unique' error | |
$scope.emailError = true; | 35 | 36 | $scope.emailError = true; | |
email.forcus(); | 36 | 37 | email.forcus(); | |
} | 37 | 38 | } | |
console.log(data); | 38 | 39 | console.log(data); | |
}); | 39 | 40 | }); | |
}; | 40 | 41 | }; | |
$scope.triggerPasswordReset = function() { | 41 | 42 | $scope.triggerPasswordReset = function() { | |
$state.go('requestpasswordreset'); | 42 | 43 | $state.go('requestpasswordreset'); | |
}; | 43 | 44 | }; | |
} | 44 | 45 | } |
templates/login_form.html
View file @
84de792
<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 class="login_input_form"> | 24 | 24 | <form name="register_form_input"> | |
<div class="form-group"> | 25 | 25 | <img ng-src="http://i.imgur.com/vkW3Lhe.jpg" ng-show="register_form_input.$dirty" /> | |
26 | <div class="form-group"> | |||
<input name="email" type="email" class="form-control" ng-model="signUpEmail" placeholder="Email" required /> | 26 | 27 | <input name="email" type="email" class="form-control" ng-model="signUpEmail" placeholder="Email" required /> | |
</div> | 27 | 28 | </div> | |
<div class="check-element animate-show" role="alert" ng-show="signUpEmail.$dirty && emailError"> | 28 | 29 | <div class="check-element animate-show" role="alert" ng-show="signUpEmail.$dirty && emailError"> | |
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | 29 | 30 | <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | |
<span style="color:#8E2323">{{signUpEmail}} already registered!</span> | 30 | 31 | <span style="color:#8E2323">{{signUpEmail}} already registered!</span> | |
</div> | 31 | 32 | </div> | |
<div class="form-group"> | 32 | 33 | <div class="form-group"> | |
<input name="password" type="password" class="form-control" ng-model="signUpPassword" placeholder="Password" required /> | 33 | 34 | <input name="password" type="password" class="form-control" ng-model="signUpPassword" placeholder="Password" required /> | |
</div> | 34 | 35 | </div> | |
<input type="submit" class="btn btn-primary btn-block" ng-click="signUp(signUpEmail, signUpPassword)" value="Sign up" /> | 35 | 36 | <input type="submit" class="btn btn-primary btn-block" ng-click="signUp(signUpEmail, signUpPassword)" value="Sign up" /> | |
</form> | 36 | 37 | </form> | |
</div> | 37 | 38 | </div> | |
38 | 39 | |||
<!-- LOGIN FORM --> | 39 | 40 | <!-- LOGIN FORM --> | |
<div class="tab-pane myform" id="tab2"> | 40 | 41 | <div class="tab-pane myform" id="tab2"> | |
<form class="login_input_form"> | 41 | 42 | <form name="login_form_input"> | |
<div class="check-element animate-show" role="alert" ng-show="loginEmail.$dirty && loginError"> | 42 | 43 | <div class="check-element animate-show" role="alert" ng-show="loginEmail.$dirty && loginError"> | |
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | 43 | 44 | <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | |
<span style="color:#8E2323">Invalid username or password!</span> | 44 | 45 | <span style="color:#8E2323">Invalid username or password!!</span> | |
</div> | 45 | 46 | </div> | |
<div class="form-group"> | 46 | 47 | <div class="form-group"> | |
<input type="email" class="form-control" ng-model="loginEmail" placeholder="Email" value="fe" /> | 47 | 48 | <input type="email" class="form-control" ng-model="loginEmail" placeholder="Email" value="fe" /> | |
</div> | 48 | 49 | </div> | |
<div class="form-group"> | 49 | 50 | <div class="form-group"> | |
<input type="password" class="form-control" ng-model="loginPassword" placeholder="Password" /> | 50 | 51 | <input type="password" class="form-control" ng-model="loginPassword" placeholder="Password" /> | |
</div> | 51 | 52 | </div> | |
<input type="submit" class="btn btn-primary btn-block" ng-click="login(loginEmail, loginPassword)" value="Login" /> | 52 | 53 | <input type="submit" class="btn btn-primary btn-block" ng-click="login(loginEmail, loginPassword)" value="Login" /> | |
</form> | 53 | 54 | </form> | |
</div> | 54 | 55 | </div> | |
</div> | 55 | 56 | </div> | |
56 | 57 | |||
<!-- FORGOT PASS --> | 57 | 58 | <!-- FORGOT PASS --> | |
<div class="disclaimer"> | 58 | 59 | <div class="disclaimer"> | |
<a class="trigger-password-reset" ng-click="triggerPasswordReset" href="#">I forgot my password</a> | 59 | 60 | <a class="trigger-password-reset" ng-click="triggerPasswordReset" href="#">forget ur password???</a> | |
</div> | 60 | 61 | </div> | |
62 | ||||
63 | <form class="test_ngshow" name="myForm"> | |||
64 | <input type="email" name="email" id="email" ng-model="wot" required /> | |||
65 | <img ng-src="http://i.imgur.com/vkW3Lhe.jpg" ng-show="myForm.$dirty" /> | |||
66 | </form> | |||
</div> | 61 | 67 | </div> | |
62 | 68 | |||
63 | 69 | |||
64 | 70 | |||
65 | 71 | |||
<!--<div> | 66 | 72 | <!--<div> | |
<input type="email" class="form-control" ng-model="loginEmail" placeholder="Email"/> | 67 | 73 | <input type="email" class="form-control" ng-model="loginEmail" placeholder="Email"/> | |
</div> | 68 | 74 | </div> | |
<div class="form-group"> | 69 | 75 | <div class="form-group"> | |
<input type="password" class="form-control" ng-model="loginPassword" placeholder="Password"/> | 70 | 76 | <input type="password" class="form-control" ng-model="loginPassword" placeholder="Password"/> | |
</div> | 71 | 77 | </div> | |
<input type="submit" class="btn btn-primary" ng-click="login(loginEmail, loginPassword)" value="LOGIN"/> | 72 | 78 | <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"/> | 73 | 79 | <input type="submit" class="btn btn-primary" ng-click="register(loginEmail, loginPassword)" value="REGISTER"/> |