Commit 0c65d0c072d5ce92d4070e1fdd3d964f816724c8
1 parent
2d0860665d
Exists in
master
and in
1 other branch
try to fix behavior when the account is locked
Showing 7 changed files with 72 additions and 79 deletions Side-by-side Diff
config.js
View file @
0c65d0c
... | ... | @@ -42,7 +42,8 @@ |
42 | 42 | if (rejection.status == 403) { |
43 | 43 | console.log(rejection); |
44 | 44 | if (rejection.data && rejection.data.detail == 'Please verify your email before continuing') { |
45 | - $rootScope.$broadcast('account_locked'); | |
45 | + UserService.showLockedMessage(); | |
46 | + UserService.logout(); | |
46 | 47 | } |
47 | 48 | } |
48 | 49 | return $q.reject(rejection); |
... | ... | @@ -53,10 +54,9 @@ |
53 | 54 | $urlRouterProvider.otherwise('/404'); |
54 | 55 | var auth_resolve = { |
55 | 56 | authorize: function($q, $state, $stateParams, UserService) { |
56 | - if (UserService.noAuthRequired($state)) { | |
57 | - console.log('no auth state ' + $state.name); | |
58 | - return $state.go(state.name); | |
59 | - } | |
57 | + if (UserService.noAuthRequired($state)) { | |
58 | + return console.log('no auth state ' + $state.name); | |
59 | + } | |
60 | 60 | console.log('resolving user before continuing for ' + $state.name); |
61 | 61 | var redirectAsNeeded = function() { |
62 | 62 | if (!UserService.isLoggedIn()) { |
... | ... | @@ -65,7 +65,7 @@ |
65 | 65 | $state.go('login'); |
66 | 66 | } |
67 | 67 | if (!UserService.authorizedFor($state, $stateParams)) { |
68 | - console.log('user not authorized for ' + $state.name); | |
68 | + console.log('user not authorized for ' + $state.name); | |
69 | 69 | $state.go('addclass'); |
70 | 70 | } |
71 | 71 | }; |
home.html
View file @
0c65d0c
... | ... | @@ -27,24 +27,25 @@ |
27 | 27 | <li class="divider"></li> |
28 | 28 | <li><a ui-sref="addclass">Add Class</a></li> |
29 | 29 | </ul> |
30 | - <ul> | |
30 | + <ul ng-show="UserService.isLoggedIn()" class="left hide-on-small-and-down"> | |
31 | 31 | <li><a style="font-size:20px; font-weight:700" class="dropdown-button ng-cloak hide-on-small-and-down" |
32 | 32 | href="#!" |
33 | 33 | data-activates="classDropdown">{{currentSection.id?currentSection.short_name:"Classes"}}<i |
34 | 34 | class="mdi-navigation-arrow-drop-down right"></i></a></li> |
35 | - </ul> | |
36 | - <ul ng-show="currentSection.id && UserService.isLoggedIn()" class="left hide-on-small-and-down"> | |
37 | - <li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | |
38 | - data-position="bottom" | |
39 | - data-delay="50" data-tooltip="Feed"><i | |
35 | + <li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" | |
36 | + class="tooltipped" | |
37 | + data-position="bottom" | |
38 | + data-delay="50" data-tooltip="Feed"><i | |
40 | 39 | class="mdi-action-view-module"></i></a></li> |
41 | - <li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | |
42 | - data-position="bottom" | |
43 | - data-delay="50" data-tooltip="Deck"><i | |
40 | + <li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" | |
41 | + class="tooltipped" | |
42 | + data-position="bottom" | |
43 | + data-delay="50" data-tooltip="Deck"><i | |
44 | 44 | class="mdi-action-view-carousel"></i></a></li> |
45 | - <li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | |
46 | - data-position="bottom" | |
47 | - data-delay="50" data-tooltip="Card List"><i | |
45 | + <li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" | |
46 | + class="tooltipped" | |
47 | + data-position="bottom" | |
48 | + data-delay="50" data-tooltip="Card List"><i | |
48 | 49 | class="mdi-action-view-list"></i></a></li> |
49 | 50 | </ul> |
50 | 51 | <a href="#" class="brand-logo center">Flashy</a> |
scripts/FeedController.js
View file @
0c65d0c
... | ... | @@ -118,7 +118,7 @@ |
118 | 118 | console.log(card); |
119 | 119 | return -1; |
120 | 120 | }; |
121 | - | |
121 | + | |
122 | 122 | $scope.update = function(id, new_score) { |
123 | 123 | card = $scope.cardTable[id].obj; |
124 | 124 | if (Math.abs(new_score - card.score) < .0001) { |
... | ... | @@ -130,7 +130,7 @@ |
130 | 130 | var column = $scope.cardCols[$scope.cardTable[id].colNum]; |
131 | 131 | var found = column.indexOf(card); |
132 | 132 | var i = 0; |
133 | - for (; i < column.length; i++) | |
133 | + for (; i < column.length; i++) | |
134 | 134 | if (column[i].score <= new_score) break; |
135 | 135 | card.score = new_score; |
136 | 136 | if ($scope.$$phase) { // most of the time it is "$digest" |
scripts/RootController.js
View file @
0c65d0c
... | ... | @@ -57,15 +57,6 @@ |
57 | 57 | ws.onclose = function(e) { |
58 | 58 | console.log('connection closed'); |
59 | 59 | }; |
60 | - $rootScope.$on('account_locked', function() { | |
61 | - UserService.logout(); | |
62 | - if ($rootScope.locked_toast_active) return; | |
63 | - $rootScope.locked_toast_active = true; | |
64 | - Materialize.toast('Thanks for trying Flashy! To ensure quality content, we ask that you verify your email before continuing', 4000, '', function() { | |
65 | - $rootScope.locked_toast_active = undefined; | |
66 | - }); | |
67 | - $state.go('login'); | |
68 | - }); | |
69 | 60 | |
70 | 61 | $rootScope.$on('server_error', function(error) { |
71 | 62 | Materialize.toast('A server error occurred! Proceed with caution', 4000); |
scripts/UserService.js
View file @
0c65d0c
... | ... | @@ -3,12 +3,16 @@ |
3 | 3 | var deferred = $q.defer(); |
4 | 4 | var _user = false; |
5 | 5 | var login = function(data) { |
6 | - _user = data; | |
6 | + if (data.locked) { | |
7 | + $rootScope.UserService.showLockedMessage(); | |
8 | + return deferred.reject('account locked'); | |
9 | + } | |
7 | 10 | if (!data.is_confirmed) { |
8 | 11 | Materialize.toast('Please verify your email address! ' + |
9 | - '<a class="btn-flat cyan-text" ng-click="UserService.resendConfirmationEmail()">' + | |
12 | + '<a class="btn-flat cyan-text" onclick="rootscope.UserService.resendConfirmationEmail()">' + | |
10 | 13 | 'Resend Verification Email</a>', 4000); |
11 | 14 | } |
15 | + _user = data; | |
12 | 16 | _user.sectionIdList = _user.sections.map(function(x) { |
13 | 17 | return x.id; |
14 | 18 | }); |
15 | 19 | |
... | ... | @@ -66,14 +70,18 @@ |
66 | 70 | } |
67 | 71 | return true; |
68 | 72 | }; |
69 | - this.noAuthRequired = function(state) { | |
70 | - if (['verifyemail'].indexOf(state.name) >= 0) { | |
71 | - return true; | |
72 | - } | |
73 | - return false; | |
74 | - }; | |
73 | + this.showLockedMessage = function(){ | |
74 | + Materialize.toast('You must verify your email address before continuing.' + | |
75 | + '<a class="btn-flat cyan-text" onclick="rootscope.UserService.resendConfirmationEmail()">' + | |
76 | + 'Resend Verification Email</a>', 4000); | |
77 | + } | |
78 | + this.noAuthRequired = function(state) { | |
79 | + if (['verifyemail'].indexOf(state.name) >= 0) { | |
80 | + return true; | |
81 | + } | |
82 | + return false; | |
83 | + }; | |
75 | 84 | this.resendConfirmationEmail = function() { |
76 | - if (!this.isLoggedIn()) return console.log("Can't request resending a confirmation email since the user is not logged in."); | |
77 | 85 | console.log('Requesting resend of confirmation email'); |
78 | 86 | $http.post('/api/resend_confirmation_email/').success(function() { |
79 | 87 | Materialize.toast('Resent confirmation email! Check your spam folder too.', 4000); |
styles/flashy.css
View file @
0c65d0c
... | ... | @@ -373,14 +373,6 @@ |
373 | 373 | opacity: 0; |
374 | 374 | } |
375 | 375 | |
376 | -/*.repeated-card.ng-move + div div {*/ | |
377 | -/*background-color:blue;*/ | |
378 | -/*top: -150px;*/ | |
379 | -/*}*/ | |
380 | - | |
381 | -/*.repeated-card.ng-move.ng-move-active + div div{*/ | |
382 | -/*top: 0;*/ | |
383 | -} | |
384 | 376 | |
385 | 377 | /* Animation CSS END */ |
386 | 378 |
templates/settings.html
View file @
0c65d0c
1 | 1 | <div class="card" id="resetPasswordForm"> |
2 | 2 | |
3 | - <h2>Change Password</h2> | |
3 | + <h2>Change Password</h2> | |
4 | 4 | |
5 | - <div class="row"> | |
6 | - <form class="col s12"> | |
5 | + <div class="row"> | |
6 | + <form class="col s12"> | |
7 | 7 | |
8 | 8 | |
9 | - <div class="row"> | |
10 | - <div class="input-field col s12"> | |
11 | - <input id="password" type="password" ng-model="oldPassword" class="validate"> | |
12 | - <label for="password">Old Password</label> | |
13 | - </div> | |
14 | - </div> | |
15 | - | |
16 | - <div class="row"> | |
17 | - <div class="input-field col s12"> | |
18 | - <input id="password" type="password" ng-model="newPassword" class="validate"> | |
19 | - <label for="password">New Password</label> | |
20 | - </div> | |
21 | - </div> | |
22 | - | |
23 | - <div class="row"> | |
24 | - <div class="input-field col s12"> | |
25 | - <input id="password" type="password" ng-model="confirmedNewPassword" class="validate"> | |
26 | - <label for="password">Confirm New Password</label> | |
27 | - </div> | |
28 | - </div> | |
29 | - | |
30 | - | |
31 | - </form> | |
32 | - | |
33 | - <a class="waves-effect waves-light btn" id="resetPWButton" ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Reset Password</a> | |
34 | - | |
35 | - </div> | |
9 | + <div class="row"> | |
10 | + <div class="input-field col s12"> | |
11 | + <input id="password" type="password" ng-model="oldPassword" class="validate"> | |
12 | + <label for="password">Old Password</label> | |
13 | + </div> | |
14 | + </div> | |
15 | + | |
16 | + <div class="row"> | |
17 | + <div class="input-field col s12"> | |
18 | + <input id="password" type="password" ng-model="newPassword" class="validate"> | |
19 | + <label for="password">New Password</label> | |
20 | + </div> | |
21 | + </div> | |
22 | + | |
23 | + <div class="row"> | |
24 | + <div class="input-field col s12"> | |
25 | + <input id="password" type="password" ng-model="confirmedNewPassword" class="validate"> | |
26 | + <label for="password">Confirm New Password</label> | |
27 | + </div> | |
28 | + </div> | |
29 | + | |
30 | + | |
31 | + </form> | |
32 | + | |
33 | + <a class="waves-effect waves-light btn" id="resetPWButton" | |
34 | + ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Reset Password</a> | |
35 | + | |
36 | + </div> | |
36 | 37 | </div> |