Compare View

switch
from
...
to
 
Commits (2)

Diff

Showing 2 changed files Side-by-side Diff

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