Commit f29eea44a18ac77233e98a8ccc76319835912a60
1 parent
c9444dfd42
Exists in
master
and in
1 other branch
materialized resetpass and requestpasswordreset
Showing 4 changed files with 66 additions and 52 deletions Inline Diff
scripts/RequestResetController.js
View file @
f29eea4
angular.module('flashy.RequestResetController', ['ui.router']) | 1 | 1 | angular.module('flashy.RequestResetController', ['ui.router']) | |
2 | 2 | |||
.controller('RequestResetController', ['$scope', '$state', '$http', | 3 | 3 | .controller('RequestResetController', ['$scope', '$state', '$http', | |
function($scope, $state, $http) { | 4 | 4 | function($scope, $state, $http) { | |
'use strict'; | 5 | 5 | 'use strict'; | |
$scope.success = false; | 6 | 6 | $scope.success = false; | |
$scope.invalid = false; | 7 | 7 | $scope.error = false; | |
$scope.resetPass = function(email) { | 8 | 8 | $scope.resetPass = function(email) { | |
$http.post('/api/request_password_reset', JSON.stringify({ | 9 | 9 | $http.post('/api/request_password_reset', JSON.stringify({ | |
'email': email | 10 | 10 | 'email': email | |
})) | 11 | 11 | })) | |
.success(function(data) { | 12 | 12 | .success(function(data) { | |
$scope.success = true; | 13 | 13 | $scope.success = true; | |
$state.go('passwordreset'); | 14 | 14 | $state.go('passwordreset'); | |
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.email) { | 18 | 18 | if (data.email) { | |
$scope.invalid = true; | 19 | 19 | $scope.error = true; | |
} | 20 | 20 | } | |
console.log(data); | 21 | 21 | console.log(data); | |
}); | 22 | 22 | }); | |
}; | 23 | 23 | }; | |
$scope.cancelReset = function() { | 24 | 24 | $scope.cancelReset = function() { | |
$state.go('login'); | 25 | 25 | $state.go('login'); | |
}; | 26 | 26 | }; | |
} | 27 | 27 | } | |
]); | 28 | 28 | ]); | |
29 | 29 |
scripts/ResetPasswordController.js
View file @
f29eea4
angular.module('flashy.ResetPasswordController', ['ui.router']). | 1 | 1 | angular.module('flashy.ResetPasswordController', ['ui.router']). | |
2 | 2 | |||
controller('ResetPasswordController', ['$scope', '$state', '$http', | 3 | 3 | controller('ResetPasswordController', ['$scope', '$state', '$http', | |
function($scope, $state, $http) { | 4 | 4 | function($scope, $state, $http) { | |
'use strict'; | 5 | 5 | 'use strict'; | |
var url = document.location.href.split("/"); | 6 | 6 | var url = document.location.href.split('/'); | |
var token = url[url.length-1]; | 7 | 7 | var token = url[url.length-1]; | |
var uid = url[url.length-2]; | 8 | 8 | var uid = url[url.length-2]; | |
$scope.error = false; | 9 | 9 | $scope.error = false; | |
10 | /*if(token == 'resetpassword') { | |||
11 | $state.go('login'); | |||
12 | }*/ | |||
$scope.confirmResetPass = function(newPassword) { | 10 | 13 | $scope.confirmResetPass = function(newPassword) { | |
$http.post('/api/reset_password', JSON.stringify({ | 11 | 14 | $http.post('/api/reset_password', JSON.stringify({ | |
'uid': uid, | 12 | 15 | 'uid': uid, | |
'token': token | 13 | 16 | 'token': token | |
})) | 14 | 17 | })) | |
.success(function(data) { | 15 | 18 | .success(function(data) { | |
$scope.error = false; | 16 | 19 | $scope.error = false; | |
$state.go('resetpasssuccess'); | 17 | 20 | $state.go('resetpasssuccess'); | |
console.log(data); | 18 | 21 | console.log(data); | |
}) | 19 | 22 | }) | |
.error(function(data, status, header, config) { | 20 | 23 | .error(function(data, status, header, config) { | |
$scope.error = true; | 21 | 24 | $scope.error = true; | |
console.log(data); | 22 | 25 | console.log(data); | |
}); | 23 | 26 | }); | |
}; | 24 | 27 | }; | |
$scope.cancelReset = function() { | 25 | 28 | $scope.cancelReset = function() { | |
$state.go('login'); | 26 | 29 | $state.go('login'); | |
}; | 27 | 30 | }; | |
} | 28 | 31 | } | |
]); | 29 | 32 | ]); |
templates/requestpasswordreset.html
View file @
f29eea4
<div class="content"> | 1 | 1 | <div class="container"> | |
<div class="container"> | 2 | 2 | <div class="row"> | |
<h1 class="text-muted">Reset Password</h1> | 3 | 3 | <div class="offset-s2 col s8"> | |
4 | <div class="card"> | |||
5 | <form class="col s12" name="passreset_form"> | |||
6 | <div class="card-content"> | |||
7 | <h2>Reset Password</h2> | |||
</div> | 4 | 8 | </div> | |
<div name="passreset" class="form-section"> | 5 | 9 | ||
<form class="form-inputs" name="passreset_form"> | 6 | 10 | <div class="divider"></div> | |
<div class="check-element animate-show" role="alert" ng-show="invalid"> | 7 | 11 | <div name="passreset" class="card-content"> | |
<span style="color:#8E2323">Enter a valid email!</span> | 8 | 12 | <div class="section"> | |
</div> | 9 | 13 | <div ng-show="error" role="error"> | |
<!--FORM INPUTS--> | 10 | 14 | <i style="color:#8E2323" class="mdi-alert-error"></i> | |
<div class="form-group"> | 11 | 15 | <span style="color:#8E2323">Enter a valid email!</span> | |
<input type="email" class="form-control" ng-model="user_email" placeholder="Email" required /> | 12 | 16 | </div> | |
</div> | 13 | 17 | </div> | |
<div class="row"> | 14 | 18 | <!--FORM INPUT--> | |
<div class="btn-group"> | 15 | 19 | <input id="email" type="email" class="form-control" ng-model="user_email" placeholder="Email" required /> | |
<button type="button" class="btn btn-default" ng-click="cancelReset()"><strong>Cancel</strong></button> | 16 | 20 | <label for="email">Enter Your Email</label> | |
</div> | 17 | 21 | </div> | |
<div class="last-button"> | 18 | 22 | ||
<div class="btn-group"> | 19 | 23 | <div class="card-action"> | |
<button type="button" class="btn btn-danger" ng-click="resetPass(user_email)"><strong>Reset Password</strong></button> | 20 | 24 | <button class="btn waves-effect waves-light red" type="submit" name="action" | |
</div> | 21 | 25 | ng-click="cancelReset()">Cancel</button> | |
</div> | 22 | 26 | <button class="btn waves-effect waves-light green right" type="submit" name="action" | |
</div> | 23 | 27 | ng-click="resetPass(user_email)">Reset</button> | |
</form> | 24 | 28 | </div> | |
</div> | 25 | 29 | </form> | |
30 | </div> | |||
31 | </div> | |||
32 | </div> | |||
</div> | 26 | 33 | </div> | |
templates/resetpassword.html
View file @
f29eea4
<div class="container"> | 1 | 1 | <div class="container"> | |
<div class="row"> | 2 | 2 | <div class="row"> | |
<h1>Reset Password</h1> | 3 | 3 | <div class="offset-s2 col s8"> | |
</div> | 4 | 4 | <div class="card"> | |
5 | 5 | <form class="col s12" name="resetpass_form"> | ||
<div class="row"> | 6 | 6 | <div class="card-content"> | |
<form class="col s12"> | 7 | 7 | <h2>Reset Password</h2> | |
<div class="row" ng-show="error" role="alert"> | 8 | 8 | </div> | |
<i style="color:#8E2323" class="mdi-alert-error"></i> | 9 | 9 | ||
<span style="color:#8E2323">Please use link from email!</span> | 10 | 10 | <div class="divider"></div> | |
11 | <div class="card-content"> | |||
12 | <div class="section"> | |||
13 | <div ng-show="error" role="alert"> | |||
14 | <i style="color:#8E2323" class="mdi-alert-error"></i> | |||
15 | <span style="color:#8E2323">Please check your reset password link!</span> | |||
16 | </div> | |||
</div> | 11 | 17 | </div> | |
<div class="row"> | 12 | 18 | <input id="newpassword" type="password" class="validate" ng-model="newPassword" placeholder="New password" required/> | |
<input id="newpassword" type="password" class="validate" ng-model="newPassword" placeholder="New password" required/> | 13 | 19 | <label for="newpassword">Password</label> | |
<label for="newpassword">New password</label> | 14 | 20 | <input id="confirmpassword" type="password" class="validate" ng-model="confirmPassword" placeholder="Confirm password" required/> | |
</div> | 15 | 21 | <label for="confirmpassword">Confirm password</label> | |
<div class="row"> | 16 | 22 | </div> | |
<input id="confirmpassword" type="password" class="validate" ng-model="confirmPassword" placeholder="Confirm password" required/> | 17 | 23 | ||
<label for="confirmpassword">Confirm password</label> | 18 | 24 | <div class="card-action"> | |
</div> | 19 | |||
</form> | 20 | |||
<div class="row"> | 21 | |||
<button class="btn waves-effect waves-light red" type="submit" name="action" | 22 | 25 | <button class="btn waves-effect waves-light red" type="submit" name="action" | |
ng-click="cancelReset()">Cancel | 23 | 26 | ng-click="cancelReset()">Cancel</button> | |
</button> | 24 | 27 | <button class="btn waves-effect waves-light green right" type="submit" name="action" | |
<button class="btn waves-effect waves-light green" type="submit" name="action" | 25 | 28 | ng-click="confirmResetPass(newPassword)">Confirm</button> | |
ng-click="confirmResetPass(newPassword)">Confirm | 26 | |||
</button> | 27 | |||
</div> | 28 | 29 | </div> | |
</div> | 29 | 30 | </form> | |
31 | </div> | |||
32 | </div> | |||
33 | </div> | |||
</div> | 30 | 34 | </div> | |