Update for tags route.

This commit is contained in:
kunw 2017-04-28 11:04:45 +08:00
parent 0a8840ee06
commit ed488e683d
2 changed files with 21 additions and 11 deletions

View File

@ -94,6 +94,7 @@ const harborRoutes: Routes = [
{ {
path: 'tags/:id/:repo', path: 'tags/:id/:repo',
component: TagRepositoryComponent, component: TagRepositoryComponent,
canActivate: [MemberGuard],
resolve: { resolve: {
projectResolver: ProjectRoutingResolver projectResolver: ProjectRoutingResolver
} }

View File

@ -33,20 +33,29 @@ export class MemberGuard implements CanActivate, CanActivateChild {
let projectId = route.params['id']; let projectId = route.params['id'];
this.sessionService.setProjectMembers([]); this.sessionService.setProjectMembers([]);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.projectService.checkProjectMember(projectId) if(!this.sessionService.getCurrentUser()) {
.subscribe( return resolve(true);
res=>{ }
this.sessionService.setProjectMembers(res); this.projectService.checkProjectMember(projectId)
return resolve(true) .subscribe(
}, res=>{
error => { this.sessionService.setProjectMembers(res);
//Add exception for repository in project detail router activation. return resolve(true)
if(state.url.endsWith('repository')) { },
error => {
//Add exception for repository in project detail router activation.
if(state.url.endsWith('repository')) {
return resolve(true); return resolve(true);
}
this.projectService.getProject(projectId).subscribe(project=>{
if(project.public === 1) {
return resolve(true);
} else {
this.router.navigate([CommonRoutes.HARBOR_DEFAULT]);
return resolve(false);
} }
this.router.navigate([CommonRoutes.HARBOR_DEFAULT]);
return resolve(false);
}); });
});
}); });
} }