added error messages to login flow
This commit is contained in:
parent
08527d5aea
commit
864a47f502
3 changed files with 21 additions and 6 deletions
|
@ -1,11 +1,17 @@
|
|||
(function () {
|
||||
|
||||
function UserLoginCtrl($scope, $window) {
|
||||
// attempts to extract an error message from
|
||||
// the URL hash in format #error=?
|
||||
$scope.error = $window.location.hash.substr(7);
|
||||
}
|
||||
|
||||
/**
|
||||
* UserCtrl is responsible for managing user settings.
|
||||
*/
|
||||
*/
|
||||
function UserCtrl($scope, users, tokens) {
|
||||
|
||||
// Gets the currently authenticated user
|
||||
// Gets the currently authenticated user
|
||||
users.getCurrent().then(function(payload){
|
||||
$scope.user = payload.data;
|
||||
});
|
||||
|
@ -34,9 +40,9 @@
|
|||
/**
|
||||
* UsersCtrl is responsible for managing user accounts.
|
||||
* This part of the site is for administrators only.
|
||||
*/
|
||||
*/
|
||||
function UsersCtrl($scope, users) {
|
||||
// Gets the currently authenticated user
|
||||
// Gets the currently authenticated user
|
||||
users.getCached().then(function(payload){
|
||||
$scope.user = payload.data;
|
||||
});
|
||||
|
@ -68,6 +74,7 @@
|
|||
|
||||
angular
|
||||
.module('drone')
|
||||
.controller('UserLoginCtrl', UserLoginCtrl)
|
||||
.controller('UserCtrl', UserCtrl)
|
||||
.controller('UsersCtrl', UsersCtrl);
|
||||
})();
|
||||
})();
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
})
|
||||
.when('/login', {
|
||||
templateUrl: '/static/scripts/views/login.html',
|
||||
controller: 'UserLoginCtrl'
|
||||
})
|
||||
.when('/profile', {
|
||||
templateUrl: '/static/scripts/views/user.html',
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
<h1>Login</h1>
|
||||
|
||||
<a href="/authorize" target="_self">Login</a>
|
||||
<div ng-switch="error">
|
||||
<div ng-switch-when="internal_error">Oops. There was an unexpected error. Please try again.</div>
|
||||
<div ng-switch-when="user_not_found">There was an error authorizing your account.</div>
|
||||
<div ng-switch-when="access_denied_org">Login is restricted to approved organization members only</div>
|
||||
<div ng-switch-when="access_denied">Self-registration is disabled. Please contact the system admin to grant access.</div>
|
||||
</div>
|
||||
|
||||
<a href="/authorize" target="_self">Login</a>
|
||||
|
|
Loading…
Reference in a new issue