Commit 148735bcc77063b3daef55beb3ec787f8d9413e9
1 parent
6f2c93016e
Exists in
master
and in
1 other branch
added resetpassword
Showing 5 changed files with 69 additions and 3 deletions Side-by-side Diff
config.js
View file @
148735b
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | 'flashy.ClassAddController', |
8 | 8 | 'flashy.RequestResetController', |
9 | 9 | 'flashy.UserService', |
10 | + 'flashy.ResetPasswordController', | |
10 | 11 | 'ngCookies']). |
11 | 12 | config(['$stateProvider', '$urlRouterProvider', '$httpProvider', |
12 | 13 | '$locationProvider', |
... | ... | @@ -52,7 +53,12 @@ |
52 | 53 | url: '/requestpasswordreset', |
53 | 54 | templateUrl: 'templates/requestpasswordreset.html', |
54 | 55 | controller: 'RequestResetController' |
55 | - }); | |
56 | + }). | |
57 | + state('resetpassword', { | |
58 | + url: '/resetpassword', | |
59 | + templateUrl: 'templates/resetpassword.html', | |
60 | + controller: 'ResetPasswordController' | |
61 | + }); | |
56 | 62 | |
57 | 63 | }]); |
home.html
View file @
148735b
... | ... | @@ -30,6 +30,7 @@ |
30 | 30 | <script src="scripts/RequestResetController.js"></script> |
31 | 31 | <script src="scripts/ClassAddController.js"></script> |
32 | 32 | <script src="scripts/UserService.js"></script> |
33 | +<script src="scripts/ResetPasswordController.js"></script> | |
33 | 34 | <script src="//ghiden.github.io/angucomplete-alt/js/libs/angucomplete-alt.js"></script> |
34 | 35 | <!--<script src="scripts/bootstrap.js"></script>--> |
35 | 36 |
scripts/ResetPasswordController.js
View file @
148735b
1 | +angular.module('flashy.ResetPasswordController', ['ui.router']). | |
2 | + | |
3 | + controller('ResetPasswordController', ['$scope', '$state', '$http', | |
4 | + function($scope, $state, $http) { | |
5 | + 'use strict'; | |
6 | + var url = document.location.href.split("/"); | |
7 | + var token = url[url.length-1]; | |
8 | + var uid = url[url.length-2]; | |
9 | + $scope.error = false; | |
10 | + $scope.confirmResetPass = function(newPassword) { | |
11 | + $http.post('/api/reset_password', JSON.stringify({ | |
12 | + 'uid': uid, | |
13 | + 'token': token | |
14 | + })) | |
15 | + .success(function(data) { | |
16 | + $scope.error = false; | |
17 | + $state.go('resetpasssuccess'); | |
18 | + console.log(data); | |
19 | + }) | |
20 | + .error(function(data, status, header, config) { | |
21 | + $scope.error = true; | |
22 | + console.log(data); | |
23 | + }); | |
24 | + }; | |
25 | + $scope.cancelReset = function() { | |
26 | + $state.go('login'); | |
27 | + }; | |
28 | + } | |
29 | + ]); |
templates/login.html
View file @
148735b
... | ... | @@ -13,13 +13,13 @@ |
13 | 13 | </div> |
14 | 14 | <div class="row"> |
15 | 15 | <div class="input-field col s6"> |
16 | - <input type="email" class="validate" ng-model="loginEmail" placeholder="Email" required/> | |
16 | + <input id="email" type="email" class="validate" ng-model="loginEmail" placeholder="Email" required/> | |
17 | 17 | <label for="email">Email</label> |
18 | 18 | </div> |
19 | 19 | </div> |
20 | 20 | <div class="row"> |
21 | 21 | <div class="input-field col s6"> |
22 | - <input type="password" class="validate" ng-model="loginPassword" placeholder="Password" required/> | |
22 | + <input id="password" type="password" class="validate" ng-model="loginPassword" placeholder="Password" required/> | |
23 | 23 | <label for="password">Password</label> |
24 | 24 | </div> |
25 | 25 | </div> |
templates/resetpassword.html
View file @
148735b
1 | +<div class="container"> | |
2 | + <div class="row"> | |
3 | + <h1>Reset Password</h1> | |
4 | + </div> | |
5 | + | |
6 | + <div class="row"> | |
7 | + <form class="col s12"> | |
8 | + <div class="row" ng-show="error" role="alert"> | |
9 | + <i style="color:#8E2323" class="mdi-alert-error"></i> | |
10 | + <span style="color:#8E2323">Please use link from email!</span> | |
11 | + </div> | |
12 | + <div class="row"> | |
13 | + <input id="newpassword" type="password" class="validate" ng-model="newPassword" placeholder="New password" required/> | |
14 | + <label for="newpassword">New password</label> | |
15 | + </div> | |
16 | + <div class="row"> | |
17 | + <input id="confirmpassword" type="password" class="validate" ng-model="confirmPassword" placeholder="Confirm password" required/> | |
18 | + <label for="confirmpassword">Confirm password</label> | |
19 | + </div> | |
20 | + </form> | |
21 | + <div class="row"> | |
22 | + <button class="btn waves-effect waves-light red" type="submit" name="action" | |
23 | + ng-click="cancelReset()">Cancel | |
24 | + </button> | |
25 | + <button class="btn waves-effect waves-light green" type="submit" name="action" | |
26 | + ng-click="confirmResetPass(newPassword)">Confirm | |
27 | + </button> | |
28 | + </div> | |
29 | + </div> | |
30 | +</div> |