Compare View
Commits (2)
Diff
Showing 2 changed files Side-by-side Diff
scripts/SettingsController.js
View file @
f59b0f7
... | ... | @@ -6,28 +6,44 @@ angular.module('flashy.SettingsController', ['ui.router']). |
6 | 6 | $scope.mismatch = false; |
7 | 7 | $scope.unacceptable = false; |
8 | 8 | |
9 | + | |
9 | 10 | $scope.changePassword = function(oldPassword, newPassword, confirmedNewPassword) { |
10 | 11 | console.log('in change password'); |
11 | 12 | |
12 | - if (newPassword != $scope.confirmedNewPassword) { | |
13 | + | |
14 | + | |
15 | + if ($scope.ChangePasswordForm.newpw.$error.minlength == true) { | |
16 | + | |
17 | + $scope.unacceptable = true; | |
18 | + console.log('unacceptable password'); | |
19 | + return; | |
20 | + } | |
21 | + | |
22 | + if (newPassword != confirmedNewPassword) { | |
13 | 23 | $scope.mismatch = true; |
14 | 24 | console.log('mismatch'); |
15 | 25 | return; |
16 | - } | |
26 | + } else { | |
27 | + | |
28 | + $scope.mismatch = false; | |
29 | + | |
30 | + } | |
17 | 31 | |
32 | + | |
33 | + | |
18 | 34 | $http.patch('/api/me/', { |
19 | 35 | 'old_password': oldPassword, |
20 | 36 | 'new_password': newPassword |
21 | 37 | }) |
22 | 38 | .success(function(data) { |
23 | 39 | console.log('password successfully changes'); |
24 | - Materialize.toast('Your password was successfully changed'); | |
40 | + Materialize.toast('Your password was successfully changed', 3000); | |
25 | 41 | $state.go('login'); |
42 | + | |
26 | 43 | }) |
27 | 44 | .error(function(data) { |
28 | 45 | console.log('problem changing the password'); |
29 | - Materialize.toast('Your old password is not correct'); | |
30 | - $state.go('login'); | |
46 | + Materialize.toast('Your old password is not correct', 3000); | |
31 | 47 | }); |
32 | 48 | }; |
33 | 49 |
templates/settings.html
View file @
f59b0f7
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | |
23 | 23 | <div class="row"> |
24 | 24 | <div class="input-field col s12"> |
25 | - <input id="password" required ng-minlegnth=1 type="password" name="oldpw" ng-model="oldPassword" class="validate"> | |
25 | + <input id="password" required ng-minlength=8 type="password" name="oldpw" ng-model="oldPassword" class="validate"> | |
26 | 26 | <label for="password">Old Password</label> |
27 | 27 | </div> |
28 | 28 | </div> |
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | </div> |
38 | 38 | |
39 | 39 | <div role="alert"> |
40 | - <span style="color:#8E2323" class="error" ng-show="ChangePasswordForm.newpw.$error.minlength"> | |
40 | + <span style="color:#8E2323" class="error" ng-show="unacceptable && ChangePasswordForm.newpw.$error.minlength"> | |
41 | 41 | New password must be at least 8 characters. </span> |
42 | 42 | </div> |
43 | 43 | |
... | ... | @@ -53,10 +53,11 @@ |
53 | 53 | <span style="color:#8E2323">Passwords do not match!</span> |
54 | 54 | </div> |
55 | 55 | |
56 | - | |
57 | - </form> | |
58 | 56 | <a class="waves-effect waves-light btn" id="resetPWButton" |
59 | 57 | ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Submit</a> |
58 | + | |
59 | + </form> | |
60 | + | |
60 | 61 | </div> |
61 | 62 | </div> |
62 | 63 | </div> |