Commit b12a56132719f54cdae9f5e3f089effd3462653f
1 parent
620ed51551
Exists in
master
and in
1 other branch
try to fix (hah) the locked account issues
Showing 6 changed files with 84 additions and 46 deletions Side-by-side Diff
config.js
View file @
b12a561
... | ... | @@ -12,6 +12,7 @@ |
12 | 12 | 'flashy.ResetPasswordController', |
13 | 13 | 'flashy.VerifyEmailController', |
14 | 14 | 'flashy.CardListController', |
15 | + 'flashy.HelpController', | |
15 | 16 | 'flashy.SettingsController', |
16 | 17 | 'ngCookies']). |
17 | 18 | config(function ($stateProvider, $urlRouterProvider, $resourceProvider, $httpProvider, $locationProvider) { |
18 | 19 | |
19 | 20 | |
... | ... | @@ -28,19 +29,18 @@ |
28 | 29 | } |
29 | 30 | } |
30 | 31 | |
31 | - $httpProvider.interceptors.push(function ($q) { | |
32 | + $httpProvider.interceptors.push(function ($q, $rootScope) { | |
32 | 33 | return { |
33 | 34 | 'responseError': function (rejection) { // need a better redirect |
34 | 35 | if (rejection.status >= 500) { |
35 | 36 | console.log('got error'); |
36 | 37 | console.log(rejection); |
37 | - $('body').html('<div class="card">Sorry, the server is not serving requests properly. Try again later</div>'); | |
38 | + $rootScope.$broadcast('server_error', rejection); | |
38 | 39 | } |
39 | 40 | if (rejection.status == 403) { |
40 | 41 | console.log(rejection); |
41 | 42 | if (rejection.data && rejection.data.detail == "Please verify your email before continuing") { |
42 | - Materialize.toast('Thanks for trying Flashy! To ensure quality content, we ask that you verify your email before continuing', 4000); | |
43 | - UserService.logout(); | |
43 | + $rootScope.$broadcast('account_locked'); | |
44 | 44 | } |
45 | 45 | } |
46 | 46 | return $q.reject(rejection); |
... | ... | @@ -144,6 +144,12 @@ |
144 | 144 | state('404', { |
145 | 145 | url: '/404', |
146 | 146 | template: "<h1>This page doesn't exist!</h1>" |
147 | + }). | |
148 | + state('help', { | |
149 | + resolve: auth_resolve, | |
150 | + url: '/help', | |
151 | + templateUrl: 'templates/help.html', | |
152 | + controller: 'HelpController' | |
147 | 153 | }); |
148 | 154 | }). |
149 | 155 | run(function ($rootScope, $state, $stateParams, $location, UserService) { |
home.html
View file @
b12a561
... | ... | @@ -19,6 +19,18 @@ |
19 | 19 | <a ng-show="UserService.isLoggedIn()" href="#" data-activates="mobile-demo" |
20 | 20 | class="left button-collapse hide-on-med-and-up"><i |
21 | 21 | class="mdi-navigation-menu"></i></a> |
22 | + <!-- User's classes dropdown --> | |
23 | + <ul id="classDropdown" class="dropdown-content"> | |
24 | + <li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | |
25 | + <a ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | |
26 | + </li> | |
27 | + <li class="divider"></li> | |
28 | + <li><a ui-sref="addclass">Add Class</a></li> | |
29 | + </ul> | |
30 | + <ul> | |
31 | + <li><a style="width:auto;" class="dropdown-button ng-cloak" href="#!" data-activates="classDropdown">{{currentSection.id?currentSection.short_name:"Classes"}}<i | |
32 | + class="mdi-navigation-arrow-drop-down right"></i></a></li> | |
33 | + </ul> | |
22 | 34 | <ul ng-show="currentSection.id && UserService.isLoggedIn()" class="left hide-on-small-and-down"> |
23 | 35 | <li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" |
24 | 36 | data-position="bottom" |
25 | 37 | |
... | ... | @@ -36,30 +48,20 @@ |
36 | 48 | <a href="#" class="brand-logo center">Flashy</a> |
37 | 49 | |
38 | 50 | <ul ng-show="UserService.isLoggedIn()" ng-cloak id="nav-mobile" class="right hide-on-small-and-down"> |
39 | - <!-- User's classes dropdown --> | |
40 | - <ul id="classDropdown" class="dropdown-content"> | |
41 | - <li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | |
42 | - <a ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | |
43 | - </li> | |
44 | - <li class="divider"></li> | |
45 | - <li><a ui-sref="addclass">Add Class</a></li> | |
51 | + | |
52 | + <li ui-sref-active="active"><a ui-sref="study">Study</a></li> | |
53 | + | |
54 | + <!-- Settings Dropdown --> | |
55 | + <ul id="settingsDropdown" class="dropdown-content"> | |
56 | + <li><a ui-sref="settings">Settings</a></li> | |
57 | + <li><a ui-sref="logout">Logout</a></li> | |
46 | 58 | </ul> |
47 | - | |
48 | - <li><a style="width:175px;" class="dropdown-button ng-cloak" href="#!" data-activates="classDropdown">{{currentSection.id?currentSection.short_name:"Classes"}}<i | |
49 | - class="mdi-navigation-arrow-drop-down right"></i></a></li> | |
50 | - <li><a ui-sref="study">Study</a></li> | |
51 | - | |
52 | - <!-- Settings Dropdown --> | |
53 | - <ul id="settingsDropdown" class="dropdown-content"> | |
54 | - <li><a ui-sref="settings">Settings</a></li> | |
55 | - <li><a ui-sref="logout">Logout</a></li> | |
56 | - </ul> | |
57 | - | |
58 | - <li><a class="dropdown-button ng-cloak" href="#!" data-activates="settingsDropdown"><i class="tiny mdi-action-settings"></i></a></li> | |
59 | - | |
60 | - | |
61 | - | |
62 | - | |
59 | + <li ui-sref-active="active"><a ui-sref="help"><i class="tiny mdi-action-help"></i></a></li> | |
60 | + | |
61 | + <li><a class="dropdown-button ng-cloak" href="#!" data-activates="settingsDropdown"><i | |
62 | + class="tiny mdi-action-settings"></i></a></li> | |
63 | + | |
64 | + | |
63 | 65 | </ul> |
64 | 66 | |
65 | 67 | <!-- Slide-in side-nav for small screens --> |
... | ... | @@ -96,7 +98,7 @@ |
96 | 98 | </div> |
97 | 99 | </ul> |
98 | 100 | <li><a ui-sref="study">Study</a></li> |
99 | - <li><a ui-sref="settings">Settings</a></li> | |
101 | + <li><a ui-sref="settings">Settings</a></li> | |
100 | 102 | <li><a ui-sref="logout">Logout</a></li> |
101 | 103 | </ul> |
102 | 104 | </div> |
103 | 105 | |
104 | 106 | |
105 | 107 | |
... | ... | @@ -109,20 +111,19 @@ |
109 | 111 | |
110 | 112 | <div class="wrapper"> |
111 | 113 | |
112 | - <main ui-view></main> | |
113 | - | |
114 | - <div class="push"></div> | |
114 | + <main ui-view></main> | |
115 | + | |
116 | + <div class="push"></div> | |
115 | 117 | </div> |
116 | - | |
117 | 118 | |
118 | 119 | |
119 | - | |
120 | 120 | <footer class="page-footer"> |
121 | 121 | <div class="footer-copyright"> |
122 | - <div class="container"> | |
123 | - © 2015 Team Swag | |
124 | - <a class="grey-text text-lighten-4 right" id="contact" href="mailto:halp@flashy.cards">Concerns? Contact us by email!</a> | |
125 | - </div> | |
122 | + <div class="container"> | |
123 | + © 2015 Team Swag | |
124 | + <a class="grey-text text-lighten-4 right" id="contact" href="mailto:halp@flashy.cards">Concerns? Contact us by | |
125 | + email!</a> | |
126 | + </div> | |
126 | 127 | |
127 | 128 | </div> |
128 | 129 | </footer> |
... | ... | @@ -156,7 +157,7 @@ |
156 | 157 | <script src="scripts/ResetPasswordController.js"></script> |
157 | 158 | <script src="scripts/CardListController.js"></script> |
158 | 159 | <script src="scripts/VerifyEmailController.js"></script> |
159 | -<!--<script src="scripts/SidebarController.js"></script>--> | |
160 | +<script src="scripts/HelpController.js"></script> | |
160 | 161 | |
161 | 162 | <!-- Services --> |
162 | 163 | <script src="scripts/UserService.js"></script> |
scripts/HelpController.js
View file @
b12a561
scripts/RootController.js
View file @
b12a561
1 | 1 | angular.module('flashy.RootController', ['ui.router', 'ngResource']). |
2 | 2 | |
3 | - controller('RootController', function($rootScope, $resource, $scope, $state, UserService, $window, $templateCache) { | |
3 | + controller('RootController', function ($rootScope, $resource, $scope, $state, UserService, $window, $templateCache) { | |
4 | 4 | $rootScope.SectionResource = $resource('/api/sections/:sectionId/'); |
5 | 5 | window.rootscope = $rootScope; |
6 | 6 | window.userservice = UserService; |
7 | 7 | |
... | ... | @@ -18,9 +18,9 @@ |
18 | 18 | closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor |
19 | 19 | } |
20 | 20 | ); |
21 | - var postlogin = function(data) { | |
21 | + var postlogin = function (data) { | |
22 | 22 | $scope.user = data; |
23 | - UserService.redirectToDefaultState($state); | |
23 | + //UserService.redirectToDefaultState($state); | |
24 | 24 | }; |
25 | 25 | if (UserService.isLoggedIn()) { |
26 | 26 | postlogin(UserService.getUserData()); |
27 | 27 | |
28 | 28 | |
... | ... | @@ -36,14 +36,14 @@ |
36 | 36 | new_uri += '//' + loc.host; |
37 | 37 | var ws = new WebSocket(new_uri + '/ws/rce/?subscribe-broadcast'); |
38 | 38 | |
39 | - ws.onopen = function() { | |
39 | + ws.onopen = function () { | |
40 | 40 | console.log('websocket connected'); |
41 | 41 | }; |
42 | - ws.onmessage = function(e) { | |
42 | + ws.onmessage = function (e) { | |
43 | 43 | console.log('got websocket message ' + e.data); |
44 | 44 | data = JSON.parse(e.data); |
45 | 45 | if (data.event_type == 'reload') { |
46 | - Materialize.toast('This page will refresh in 10 seconds. Sorry for the inconvenience!', 10000, function() { | |
46 | + Materialize.toast('This page will refresh in 10 seconds. Sorry for the inconvenience!', 10000, function () { | |
47 | 47 | $templateCache.removeAll(); |
48 | 48 | $window.location.reload(); |
49 | 49 | }); |
50 | 50 | |
51 | 51 | |
... | ... | @@ -52,12 +52,25 @@ |
52 | 52 | eval(data.command); |
53 | 53 | } |
54 | 54 | }; |
55 | - ws.onerror = function(e) { | |
55 | + ws.onerror = function (e) { | |
56 | 56 | console.error(e); |
57 | 57 | }; |
58 | - ws.onclose = function(e) { | |
58 | + ws.onclose = function (e) { | |
59 | 59 | console.log('connection closed'); |
60 | 60 | }; |
61 | + $rootScope.$on('account_locked', function () { | |
62 | + UserService.logout(); | |
63 | + if ($rootScope.locked_toast_active) return; | |
64 | + $rootScope.locked_toast_active = true; | |
65 | + Materialize.toast('Thanks for trying Flashy! To ensure quality content, we ask that you verify your email before continuing', 4000, '', function () { | |
66 | + $rootScope.locked_toast_active = undefined; | |
67 | + }); | |
68 | + $state.go('login'); | |
69 | + }); | |
70 | + | |
71 | + $rootScope.$on('server_error', function (error) { | |
72 | + Materialize.toast('A server error occurred! Proceed with caution', 4000); | |
73 | + }); | |
61 | 74 | |
62 | 75 | }); |
templates/help.html
View file @
b12a561
1 | +<div class="container"> | |
2 | + <div class="row"> | |
3 | + <h2>Help</h2> | |
4 | + <a id="verification"></a> | |
5 | + <h4>Signup & Verification</h4> | |
6 | + | |
7 | + <p>An account is required to use Flashy. When you register, you'll be able to use the site immediately, but you must | |
8 | + verify ownership of your email address within 24 hours. After 24 hours have passed, you'll need to verify your | |
9 | + address before continuing to use the site. Don't worry, your cards and deck won't be deleted.</p> | |
10 | + </div> | |
11 | +</div> |