Do not redirect logged in project members with only view permissions

pull/5264/head
Wieland Lindenthal 8 years ago
parent 3612db1621
commit 289d5fcbf8
  1. 22
      frontend/app/components/wp-create/wp-create.controller.ts

@ -32,6 +32,9 @@ import {
WorkPackageResource, WorkPackageResource,
WorkPackageResourceInterface WorkPackageResourceInterface
} from '../api/api-v3/hal-resources/work-package-resource.service'; } from '../api/api-v3/hal-resources/work-package-resource.service';
import {
HalResource
} from '../api/api-v3/hal-resources/hal-resource.service';
import {WorkPackageCacheService} from "../work-packages/work-package-cache.service"; import {WorkPackageCacheService} from "../work-packages/work-package-cache.service";
import IRootScopeService = angular.IRootScopeService; import IRootScopeService = angular.IRootScopeService;
import {WorkPackageEditModeStateService} from "../wp-edit/wp-edit-mode-state.service"; import {WorkPackageEditModeStateService} from "../wp-edit/wp-edit-mode-state.service";
@ -83,7 +86,9 @@ export class WorkPackageCreateController {
protected wpCreate:WorkPackageCreateService, protected wpCreate:WorkPackageCreateService,
protected wpEditModeState:WorkPackageEditModeStateService, protected wpEditModeState:WorkPackageEditModeStateService,
protected wpTableSelection:WorkPackageTableSelection, protected wpTableSelection:WorkPackageTableSelection,
protected wpCacheService:WorkPackageCacheService) { protected wpCacheService:WorkPackageCacheService,
protected halRequest:any,
protected v3Path:any) {
this.newWorkPackageFromParams($state.params) this.newWorkPackageFromParams($state.params)
.then(wp => { .then(wp => {
@ -101,12 +106,17 @@ export class WorkPackageCreateController {
}) })
.catch(error => { .catch(error => {
if (error.errorIdentifier == "urn:openproject-org:api:v3:errors:MissingPermission") { if (error.errorIdentifier == "urn:openproject-org:api:v3:errors:MissingPermission") {
let url: string = $location.absUrl(); this.halRequest.get(this.v3Path.root()).then((root:HalResource) => {
$location.path('/login').search({back_url: url}); if (!root.user) {
let loginUrl: string = $location.absUrl(); // Not logged in
window.location.href = loginUrl; let url: string = $location.absUrl();
$location.path('/login').search({back_url: url});
let loginUrl: string = $location.absUrl();
window.location.href = loginUrl;
};
});
this.wpNotificationsService.handleErrorResponse(error);
}; };
this.wpNotificationsService.handleErrorResponse(error);
}); });
} }

Loading…
Cancel
Save