mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-22 16:48:30 +01:00
update for interceptor of global session check and others.
This commit is contained in:
parent
ae3bfba3c8
commit
597b865cf5
@ -58,10 +58,11 @@
|
||||
vm.opDelete = vm.opAll;
|
||||
vm.opOthers = vm.opAll;
|
||||
}else {
|
||||
vm.op = [];
|
||||
vm.opAll = false;
|
||||
}
|
||||
|
||||
vm.op = [];
|
||||
|
||||
if(vm.opCreate) {
|
||||
vm.op.push('create');
|
||||
}
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
vm.beginTimestamp = 0;
|
||||
vm.endTimestamp = 0;
|
||||
vm.keywords = "";
|
||||
vm.username = "";
|
||||
vm.keywords = '';
|
||||
vm.username = '';
|
||||
|
||||
vm.op = [];
|
||||
vm.opOthers = true;
|
||||
@ -48,24 +48,20 @@
|
||||
'projectId': vm.projectId,
|
||||
'username' : vm.username
|
||||
};
|
||||
vm.username = '';
|
||||
retrieve(vm.queryParams);
|
||||
});
|
||||
|
||||
function search(e) {
|
||||
|
||||
if(e.op[0] === 'all') {
|
||||
if(vm.opOthers && $.trim(vm.others) !== '') {
|
||||
e.op = [];
|
||||
e.op.push(vm.others);
|
||||
vm.queryParams.keywords = e.op.join('/');
|
||||
}else{
|
||||
vm.queryParams.keywords = '';
|
||||
}
|
||||
}else {
|
||||
if(vm.opOthers && $.trim(vm.others) !== '') {
|
||||
e.op.push(vm.others);
|
||||
}
|
||||
vm.queryParams.keywords = e.op.join('/');
|
||||
}
|
||||
e.op = ['create', 'pull', 'push', 'delete'];
|
||||
}
|
||||
if(vm.opOthers && $.trim(vm.others) !== '') {
|
||||
e.op.push(vm.others);
|
||||
}
|
||||
|
||||
vm.queryParams.keywords = e.op.join('/');
|
||||
vm.queryParams.username = e.username;
|
||||
|
||||
vm.queryParams.beginTimestamp = toUTCSeconds(vm.fromDate, 0, 0, 0);
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
$scope.$on('$locationChangeSuccess', function() {
|
||||
vm.projectId = getParameterByName('project_id', $location.absUrl());
|
||||
vm.username = '';
|
||||
vm.retrieve();
|
||||
});
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<ng-switch on="vm.editMode">
|
||||
<span ng-switch-default>//vm.currentRole.name//</span>
|
||||
<select ng-switch-when="true" ng-model="vm.currentRole" ng-options="role as role.name for role in vm.roles track by role.roleName" ng-change="vm.selectRole(vm.currentRole)">
|
||||
<select class="form-control" style="width: auto; height: auto; padding: 0;" ng-switch-when="true" ng-model="vm.currentRole" ng-options="role as role.name for role in vm.roles track by role.roleName" ng-change="vm.selectRole(vm.currentRole)">
|
||||
</select>
|
||||
</ng-switch>
|
@ -10,28 +10,31 @@
|
||||
$httpProvider.defaults.headers.common = {'Accept': 'application/json, text/javascript, */*; q=0.01'};
|
||||
$httpProvider.interceptors.push('redirectInterceptor');
|
||||
})
|
||||
.factory('redirectInterceptor', RedirectInterceptorFactory)
|
||||
.service('redirectInterceptor', RedirectInterceptorService)
|
||||
.factory('getParameterByName', getParameterByName)
|
||||
.filter('dateL', localizeDate)
|
||||
.filter('tr', tr);
|
||||
|
||||
RedirectInterceptorFactory.$inject = ['$q', '$window'];
|
||||
RedirectInterceptorService.$inject = ['$q', '$window'];
|
||||
|
||||
function RedirectInterceptorFactory($q, $window) {
|
||||
return redirectInterceptor;
|
||||
function redirectInterceptor() {
|
||||
return {
|
||||
'request' : function(r) {
|
||||
console.log('global interceptor has being triggered, "Request"');
|
||||
},
|
||||
'response': function(r) {
|
||||
console.log('global interceptor has being triggered, "Response"');
|
||||
},
|
||||
'responseError': function(rejection) {
|
||||
console.log('global interceptor has being triggered. "ResponseError"');
|
||||
function RedirectInterceptorService($q, $window) {
|
||||
return {
|
||||
'responseError': function(rejection) {
|
||||
var pathname = $window.location.pathname;
|
||||
var exclusions = ['/', '/search', '/reset_password', '/sign_up', '/forgot_password'];
|
||||
var isExcluded = false;
|
||||
for(var i in exclusions) {
|
||||
if(exclusions[i] === pathname) {
|
||||
isExcluded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
if(rejection.status === 401 && !isExcluded) {
|
||||
$window.location.href = '/';
|
||||
}
|
||||
return $q.reject(rejection);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getParameterByName() {
|
||||
|
@ -26,21 +26,7 @@
|
||||
}
|
||||
|
||||
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 = '/';
|
||||
console.log('No session of current user.');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user