mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-20 15:48:26 +01:00
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
(function() {
|
|
|
|
'use strict';
|
|
|
|
angular
|
|
.module('harbor.session')
|
|
.controller('CurrentUserController', CurrentUserController);
|
|
|
|
CurrentUserController.$inject = ['$scope', 'CurrentUserService', 'currentUser', '$window', '$document'];
|
|
|
|
function CurrentUserController($scope, CurrentUserService, currentUser, $window, $document) {
|
|
|
|
var vm = this;
|
|
|
|
CurrentUserService()
|
|
.then(getCurrentUserComplete)
|
|
.catch(getCurrentUserFailed);
|
|
|
|
function getCurrentUserComplete(response) {
|
|
if(angular.isDefined(response)) {
|
|
currentUser.set(response.data);
|
|
if(location.pathname === '/') {
|
|
$window.location.href = '/dashboard';
|
|
}
|
|
}
|
|
}
|
|
|
|
function getCurrentUserFailed(e){
|
|
var url = location.pathname;
|
|
var exclusions = [
|
|
'/',
|
|
'/forgot_password',
|
|
'/sign_up',
|
|
'/reset_password',
|
|
'/search',
|
|
'/repository'
|
|
];
|
|
for(var i = 0; i < exclusions.length; i++) {
|
|
if(exclusions[i]===url) {
|
|
return;
|
|
}
|
|
}
|
|
$window.location.href = '/';
|
|
}
|
|
}
|
|
|
|
})(); |