From 246011e2924fafd3fb67da6446b89735b8e871df Mon Sep 17 00:00:00 2001 From: Leo Luong Date: Sun, 7 Aug 2022 13:16:15 +1000 Subject: [PATCH 01/10] new: create initial files for migration of unauthorized --- .../states/unauthorised/unauthorised.component.html | 0 .../states/unauthorised/unauthorised.component.scss | 0 .../states/unauthorised/unauthorised.component.ts | 10 ++++++++++ 3 files changed, 10 insertions(+) create mode 100644 src/app/errors/states/unauthorised/unauthorised.component.html create mode 100644 src/app/errors/states/unauthorised/unauthorised.component.scss create mode 100644 src/app/errors/states/unauthorised/unauthorised.component.ts diff --git a/src/app/errors/states/unauthorised/unauthorised.component.html b/src/app/errors/states/unauthorised/unauthorised.component.html new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/errors/states/unauthorised/unauthorised.component.scss b/src/app/errors/states/unauthorised/unauthorised.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/errors/states/unauthorised/unauthorised.component.ts b/src/app/errors/states/unauthorised/unauthorised.component.ts new file mode 100644 index 000000000..60254f6f7 --- /dev/null +++ b/src/app/errors/states/unauthorised/unauthorised.component.ts @@ -0,0 +1,10 @@ +import { Component} from '@angular/core'; + +@Component({ + selector: 'unauthorised', + templateUrl: 'unauthorised.component.html', + styleUrls: ['unauthorised.component.scss'], +}) +export class UnauthorisedComponent { + constructor(){} +} \ No newline at end of file From 22611c632131b59b27374b11ace21c5ad4e0b7c3 Mon Sep 17 00:00:00 2001 From: Leo Luong Date: Sun, 7 Aug 2022 13:26:47 +1000 Subject: [PATCH 02/10] migrate:unlink old components --- src/app/doubtfire-angular.module.ts | 2 ++ src/app/doubtfire-angularjs.module.ts | 4 +++- src/app/doubtfire.states.ts | 24 ++++++++++++++++++- .../unauthorised/unauthorised.component.ts | 4 ++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/app/doubtfire-angular.module.ts b/src/app/doubtfire-angular.module.ts index febb3b816..33d494bb9 100644 --- a/src/app/doubtfire-angular.module.ts +++ b/src/app/doubtfire-angular.module.ts @@ -164,6 +164,7 @@ import { HeaderComponent } from './common/header/header.component'; import { UnitDropdownComponent } from './common/header/unit-dropdown/unit-dropdown.component'; import { TaskDropdownComponent } from './common/header/task-dropdown/task-dropdown.component'; import { SplashScreenComponent } from './home/splash-screen/splash-screen.component'; +import { UnauthorisedComponent } from './errors/states/unauthorised/unauthorised.component'; @NgModule({ // Components we declare @@ -221,6 +222,7 @@ import { SplashScreenComponent } from './home/splash-screen/splash-screen.compon UnitDropdownComponent, TaskDropdownComponent, SplashScreenComponent, + UnauthorisedComponent, ], // Module Imports imports: [ diff --git a/src/app/doubtfire-angularjs.module.ts b/src/app/doubtfire-angularjs.module.ts index c8ec2ba1d..8cc5001df 100644 --- a/src/app/doubtfire-angularjs.module.ts +++ b/src/app/doubtfire-angularjs.module.ts @@ -236,7 +236,6 @@ import 'build/src/app/api/models/unit.js'; import 'build/src/app/api/api.js'; import 'build/src/app/api/resource-plus.js'; import 'build/src/app/errors/errors.js'; -import 'build/src/app/errors/states/unauthorised/unauthorised.js'; import 'build/src/app/errors/states/not-found/not-found.js'; import 'build/src/app/errors/states/timeout/timeout.js'; import 'build/src/app/errors/states/states.js'; @@ -289,6 +288,7 @@ import { TaskAssessmentModalService } from './common/modals/task-assessment-moda import { TaskSubmissionHistoryComponent } from './tasks/task-submission-history/task-submission-history.component'; import { HeaderComponent } from './common/header/header.component'; import { GlobalStateService } from './projects/states/index/global-state.service'; +import { UnauthorisedComponent } from './errors/states/unauthorised/unauthorised.component'; export const DoubtfireAngularJSModule = angular.module('doubtfire', [ 'doubtfire.config', @@ -396,6 +396,8 @@ DoubtfireAngularJSModule.directive( downgradeComponent({ component: TaskPlagiarismCardComponent }) ); +DoubtfireAngularJSModule.directive('unauthorised', downgradeComponent({ component: UnauthorisedComponent })); + // Global configuration // If the user enters a URL that doesn't match any known URL (state), send them to `/home` diff --git a/src/app/doubtfire.states.ts b/src/app/doubtfire.states.ts index cb9b49550..b4859fac5 100644 --- a/src/app/doubtfire.states.ts +++ b/src/app/doubtfire.states.ts @@ -2,6 +2,7 @@ import { NgHybridStateDeclaration } from '@uirouter/angular-hybrid'; import { Ng2ViewDeclaration } from '@uirouter/angular'; import { InstitutionSettingsComponent } from './admin/institution-settings/institution-settings.component'; import { HomeComponent } from './home/states/home/home.component'; +import { UnauthorisedComponent } from './errors/states/unauthorised/unauthorised.component'; /* @@ -50,7 +51,28 @@ const institutionSettingsState: NgHybridStateDeclaration = { } }; +const UnauthoriedState: NgHybridStateDeclaration = { + name: 'unauthorised', + url: '/unauthorised', // You get here with this url + views: { + // These are the 2 views - the header and main from the body of DF + header: { + // Header is still angularjs + controller: 'BasicHeaderCtrl', // This is the angularjs controller + templateUrl: 'common/header/header.tpl.html', // and the related template html + } as unknown as Ng2ViewDeclaration, // Need dodgy cast to get compiler to ignore type data + main: { + // Main body links to angular component + component: UnauthorisedComponent, + }, + }, + data: { + // Add data used by header + pageTitle: 'Unauthorised', + roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin'], + }, +}; /** * Export the list of states we have created in angular */ -export const doubtfireStates = [institutionSettingsState, HomeState]; +export const doubtfireStates = [institutionSettingsState, HomeState, UnauthoriedState]; diff --git a/src/app/errors/states/unauthorised/unauthorised.component.ts b/src/app/errors/states/unauthorised/unauthorised.component.ts index 60254f6f7..a41aebb8c 100644 --- a/src/app/errors/states/unauthorised/unauthorised.component.ts +++ b/src/app/errors/states/unauthorised/unauthorised.component.ts @@ -1,4 +1,4 @@ -import { Component} from '@angular/core'; +import { Component } from '@angular/core'; @Component({ selector: 'unauthorised', @@ -7,4 +7,4 @@ import { Component} from '@angular/core'; }) export class UnauthorisedComponent { constructor(){} -} \ No newline at end of file +} From a94db3d8838355dfa763c544fdbe978bc258b066 Mon Sep 17 00:00:00 2001 From: Leo Luong Date: Sun, 7 Aug 2022 13:27:32 +1000 Subject: [PATCH 03/10] migrate:unlink old components --- .../errors/states/unauthorised/unauthorised.component.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/app/errors/states/unauthorised/unauthorised.component.html b/src/app/errors/states/unauthorised/unauthorised.component.html index e69de29bb..4f92fedc1 100644 --- a/src/app/errors/states/unauthorised/unauthorised.component.html +++ b/src/app/errors/states/unauthorised/unauthorised.component.html @@ -0,0 +1,7 @@ +
+
+ +

Unauthorised

+

You do not have sufficient permissions to access this resource, or your session has expired.

+
+
\ No newline at end of file From c269b04a3a1694cb2056313a0335f1d4f3e7f3be Mon Sep 17 00:00:00 2001 From: Leo Luong Date: Sun, 7 Aug 2022 13:30:22 +1000 Subject: [PATCH 04/10] migrate:unlink old components --- src/app/errors/states/states.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/errors/states/states.coffee b/src/app/errors/states/states.coffee index 84cdc11e2..ffcf5c77f 100644 --- a/src/app/errors/states/states.coffee +++ b/src/app/errors/states/states.coffee @@ -1,5 +1,4 @@ angular.module("doubtfire.errors.states", [ "doubtfire.errors.states.not-found" "doubtfire.errors.states.timeout" - "doubtfire.errors.states.unauthorised" ]) From 275f4c01b255060acf2c4c76803133c7615b1b6a Mon Sep 17 00:00:00 2001 From: Leo Luong Date: Sun, 7 Aug 2022 13:31:57 +1000 Subject: [PATCH 05/10] migrate: adjust style --- .../errors/states/unauthorised/unauthorised.component.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/errors/states/unauthorised/unauthorised.component.html b/src/app/errors/states/unauthorised/unauthorised.component.html index 4f92fedc1..e5566606d 100644 --- a/src/app/errors/states/unauthorised/unauthorised.component.html +++ b/src/app/errors/states/unauthorised/unauthorised.component.html @@ -1,6 +1,6 @@ -
-
- +
+
+

Unauthorised

You do not have sufficient permissions to access this resource, or your session has expired.

From 917a36b69fd3f90e9173a9fef6852507dea419bb Mon Sep 17 00:00:00 2001 From: Leo Luong Date: Sun, 7 Aug 2022 13:34:44 +1000 Subject: [PATCH 06/10] migrate: update unit test for unauthorised component --- .../unauthorised.component.spec.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/app/errors/states/unauthorised/unauthorised.component.spec.ts diff --git a/src/app/errors/states/unauthorised/unauthorised.component.spec.ts b/src/app/errors/states/unauthorised/unauthorised.component.spec.ts new file mode 100644 index 000000000..dcd275e0f --- /dev/null +++ b/src/app/errors/states/unauthorised/unauthorised.component.spec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UnauthorisedComponent } from './unauthorised.component'; + +describe('UnauthorisedComponent', () => { + let component: UnauthorisedComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [UnauthorisedComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(UnauthorisedComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); \ No newline at end of file From 97686fcad49cd1fd4af9aef266af26064fdfb186 Mon Sep 17 00:00:00 2001 From: Leo Luong Date: Fri, 9 Sep 2022 16:35:28 +1000 Subject: [PATCH 07/10] chore: update html template --- .../unauthorised/unauthorised.component.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/errors/states/unauthorised/unauthorised.component.html b/src/app/errors/states/unauthorised/unauthorised.component.html index e5566606d..a0f26d25c 100644 --- a/src/app/errors/states/unauthorised/unauthorised.component.html +++ b/src/app/errors/states/unauthorised/unauthorised.component.html @@ -1,7 +1,7 @@ -
-
- -

Unauthorised

-

You do not have sufficient permissions to access this resource, or your session has expired.

-
-
\ No newline at end of file +
+
+ +

Unauthorised

+

You do not have sufficient permissions to access this resource, or your session has expired.

+
+
\ No newline at end of file From a31cc1bfb9a03a60a0c087cb84ae559fb515b404 Mon Sep 17 00:00:00 2001 From: Leo Luong Date: Mon, 12 Sep 2022 11:15:40 +1000 Subject: [PATCH 08/10] chore: delete old files --- .../states/unauthorised/unauthorised.coffee | 19 ------------------- .../states/unauthorised/unauthorised.tpl.html | 7 ------- 2 files changed, 26 deletions(-) delete mode 100644 src/app/errors/states/unauthorised/unauthorised.coffee delete mode 100644 src/app/errors/states/unauthorised/unauthorised.tpl.html diff --git a/src/app/errors/states/unauthorised/unauthorised.coffee b/src/app/errors/states/unauthorised/unauthorised.coffee deleted file mode 100644 index 1c16b9802..000000000 --- a/src/app/errors/states/unauthorised/unauthorised.coffee +++ /dev/null @@ -1,19 +0,0 @@ -angular.module("doubtfire.errors.states.unauthorised", []) - -# -# Define the unauthorised state -# -.config((headerServiceProvider) -> - stateData = - url: "/unauthorised" - views: - main: - controller: "UnauthorisedCtrl" - templateUrl: "errors/states/unauthorised/unauthorised.tpl.html" - data: - pageTitle: "_Unauthorised_" - - headerServiceProvider.state "unauthorised", stateData -) - -.controller("UnauthorisedCtrl", ($scope) ->) diff --git a/src/app/errors/states/unauthorised/unauthorised.tpl.html b/src/app/errors/states/unauthorised/unauthorised.tpl.html deleted file mode 100644 index a0f26d25c..000000000 --- a/src/app/errors/states/unauthorised/unauthorised.tpl.html +++ /dev/null @@ -1,7 +0,0 @@ -
-
- -

Unauthorised

-

You do not have sufficient permissions to access this resource, or your session has expired.

-
-
\ No newline at end of file From 164659e66a352612ce9e66c1b37e0eec6107e004 Mon Sep 17 00:00:00 2001 From: Leo Luong Date: Tue, 13 Sep 2022 12:51:18 +1000 Subject: [PATCH 09/10] chore: upload icon --- src/app/errors/errors.scss | 10 +--------- .../unauthorised/unauthorised.component.html | 12 ++++++------ .../unauthorised/unauthorised.component.scss | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/app/errors/errors.scss b/src/app/errors/errors.scss index bb20204bc..8b1378917 100644 --- a/src/app/errors/errors.scss +++ b/src/app/errors/errors.scss @@ -1,9 +1 @@ -.error-container { - h1 + p { - margin-top: 20px; - } - i { - margin-top: 30px; - font-size: 100px; - } -} + diff --git a/src/app/errors/states/unauthorised/unauthorised.component.html b/src/app/errors/states/unauthorised/unauthorised.component.html index a0f26d25c..695410127 100644 --- a/src/app/errors/states/unauthorised/unauthorised.component.html +++ b/src/app/errors/states/unauthorised/unauthorised.component.html @@ -1,7 +1,7 @@ -
-
- -

Unauthorised

-

You do not have sufficient permissions to access this resource, or your session has expired.

+ +
+ warning
-
\ No newline at end of file +

Unauthorised

+

You do not have sufficient permissions to access this resource, or your session has expired.

+ diff --git a/src/app/errors/states/unauthorised/unauthorised.component.scss b/src/app/errors/states/unauthorised/unauthorised.component.scss index e69de29bb..52cb7522f 100644 --- a/src/app/errors/states/unauthorised/unauthorised.component.scss +++ b/src/app/errors/states/unauthorised/unauthorised.component.scss @@ -0,0 +1,14 @@ +.icon-display { + font-size: 15rem; + padding-top: 10px; + padding-bottom: 10px; + +} + +.icon-container{ + padding-right: 12rem; +} + +.text-centre{ + text-align: center; +} \ No newline at end of file From deaa1e940f8295ff962c111f1dbac75ed5ff51fa Mon Sep 17 00:00:00 2001 From: Andrew Cain Date: Mon, 4 Nov 2024 21:28:25 +1100 Subject: [PATCH 10/10] fix: ensure authorisation active in angular --- src/app/doubtfire.states.ts | 54 +++++-------------- .../states/dashboard/dashboard.coffee | 1 - src/app/projects/states/groups/groups.coffee | 1 - src/app/projects/states/index/index.coffee | 1 - .../projects/states/outcomes/outcomes.coffee | 1 - .../states/portfolio/portfolio.coffee | 1 - .../states/project-root-state.component.ts | 1 - .../states/tutorials/tutorials.coffee | 1 - src/app/sessions/transition-hooks.service.ts | 15 +++++- src/app/units/states/index/index.coffee | 2 +- src/app/units/states/tasks/inbox/inbox.coffee | 2 +- .../task-viewer-state.component.ts | 2 +- src/app/units/unit-root-state.component.ts | 2 +- 13 files changed, 31 insertions(+), 53 deletions(-) diff --git a/src/app/doubtfire.states.ts b/src/app/doubtfire.states.ts index ab4a95ff2..7baa910f5 100644 --- a/src/app/doubtfire.states.ts +++ b/src/app/doubtfire.states.ts @@ -4,17 +4,11 @@ import {HomeComponent} from './home/states/home/home.component'; import {WelcomeComponent} from './welcome/welcome.component'; import {SignInComponent} from './sessions/states/sign-in/sign-in.component'; import {EditProfileComponent} from './account/edit-profile/edit-profile.component'; -import {TeachingPeriodListComponent} from './admin/states/teaching-periods/teaching-period-list/teaching-period-list.component'; import {AcceptEulaComponent} from './eula/accept-eula/accept-eula.component'; import { UnauthorisedComponent } from './errors/states/unauthorised/unauthorised.component'; import {FUsersComponent} from './admin/states/users/users.component'; import {FUnitsComponent} from './admin/states/units/units.component'; import {ProjectDashboardComponent} from './projects/states/dashboard/project-dashboard/project-dashboard.component'; -import {AppInjector} from './app-injector'; -import {ProjectService} from './api/services/project.service'; -import {Observable, first} from 'rxjs'; -import {GlobalStateService} from './projects/states/index/global-state.service'; -import {Project} from './api/models/project'; import {UnitRootState} from './units/unit-root-state.component'; import {ProjectRootState} from './projects/states/project-root-state.component'; import { TaskViewerState } from './units/task-viewer/task-viewer-state.component'; @@ -39,7 +33,7 @@ const institutionSettingsState: NgHybridStateDeclaration = { }, data: { pageTitle: 'Institution Settings', - roleWhiteList: ['Admin'], + roleWhitelist: ['Admin'], }, }; @@ -54,7 +48,7 @@ const usersState: NgHybridStateDeclaration = { }, data: { pageTitle: 'Administer users', - roleWhiteList: ['Admin'], + roleWhitelist: ['Admin'], }, }; @@ -70,8 +64,7 @@ const HomeState: NgHybridStateDeclaration = { }, }, data: { - pageTitle: 'Home Page', - roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'], + pageTitle: 'Home Page' }, }; @@ -176,8 +169,7 @@ const WelcomeState: NgHybridStateDeclaration = { }, }, data: { - pageTitle: 'Welcome', - roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'], + pageTitle: 'Welcome' }, }; @@ -209,22 +201,7 @@ const EditProfileState: NgHybridStateDeclaration = { }, }, data: { - pageTitle: 'Edit Profile', - roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'], - }, -}; - -const TeachingPeriodsState: NgHybridStateDeclaration = { - name: 'teaching_periods', - url: '/admin/teachingperiods', - views: { - main: { - component: TeachingPeriodListComponent, - }, - }, - data: { - pageTitle: 'Teaching Periods', - roleWhitelist: ['Convenor', 'Admin'], + pageTitle: 'Edit Profile' }, }; @@ -237,8 +214,7 @@ const EulaState: NgHybridStateDeclaration = { }, }, data: { - pageTitle: 'End User License Agreement', - roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'], + pageTitle: 'End User License Agreement' }, }; @@ -256,8 +232,7 @@ const ViewAllProjectsState: NgHybridStateDeclaration = { }, }, data: { - pageTitle: 'Teaching Periods', - roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin'], + pageTitle: 'All Units' }, }; @@ -277,7 +252,7 @@ const AdministerUnits: NgHybridStateDeclaration = { }, data: { pageTitle: 'Administer units', - roleWhiteList: ['Admin'], + roleWhitelist: ['Admin', 'Convenor', 'Auditor'], }, }; @@ -292,8 +267,7 @@ const ProjectDashboardState: NgHybridStateDeclaration = { }, }, data: { - pageTitle: 'Project Dashboard', - roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin'], + pageTitle: 'Unit Dashboard', }, }; @@ -312,9 +286,9 @@ const ViewAllUnits: NgHybridStateDeclaration = { }, }, data: { - pageTitle: 'Teaching Periods', + pageTitle: 'View Units', mode: 'tutor', - roleWhitelist: ['Tutor', 'Convenor', 'Admin'], + roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor'], }, }; @@ -335,8 +309,7 @@ const UnauthoriedState: NgHybridStateDeclaration = { }, data: { // Add data used by header - pageTitle: 'Unauthorised', - roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin'], + pageTitle: 'Unauthorised' }, }; /** @@ -409,7 +382,7 @@ const ScormPlayerStudentReviewState: NgHybridStateDeclaration = { }, data: { pageTitle: 'Review Knowledge Check', - roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin'], + roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'], }, }; @@ -443,7 +416,6 @@ const ScormPlayerReviewState: NgHybridStateDeclaration = { */ export const doubtfireStates = [ institutionSettingsState, - TeachingPeriodsState, HomeState, WelcomeState, SignInState, diff --git a/src/app/projects/states/dashboard/dashboard.coffee b/src/app/projects/states/dashboard/dashboard.coffee index d4d073c8a..9e86c3b6a 100644 --- a/src/app/projects/states/dashboard/dashboard.coffee +++ b/src/app/projects/states/dashboard/dashboard.coffee @@ -16,7 +16,6 @@ angular.module('doubtfire.projects.states.dashboard', [ data: task: "Dashboard" pageTitle: "_Home_" - roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Student', 'Auditor'] } ) diff --git a/src/app/projects/states/groups/groups.coffee b/src/app/projects/states/groups/groups.coffee index a20d2c0d8..52fb04d9e 100644 --- a/src/app/projects/states/groups/groups.coffee +++ b/src/app/projects/states/groups/groups.coffee @@ -12,7 +12,6 @@ angular.module('doubtfire.projects.states.groups', []) data: task: "Groups List" pageTitle: "_Home_" - roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Student', 'Auditor'] } ) diff --git a/src/app/projects/states/index/index.coffee b/src/app/projects/states/index/index.coffee index 0b9744b95..d77b2be90 100644 --- a/src/app/projects/states/index/index.coffee +++ b/src/app/projects/states/index/index.coffee @@ -13,7 +13,6 @@ angular.module('doubtfire.projects.states.index', []) templateUrl: "units/states/index/index.tpl.html" # We can re-use unit's index here data: pageTitle: "_Home_" - roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'] } ) diff --git a/src/app/projects/states/outcomes/outcomes.coffee b/src/app/projects/states/outcomes/outcomes.coffee index 5c5d61092..cc6cd7487 100644 --- a/src/app/projects/states/outcomes/outcomes.coffee +++ b/src/app/projects/states/outcomes/outcomes.coffee @@ -12,7 +12,6 @@ angular.module('doubtfire.projects.states.outcomes', []) data: task: "Learning Outcomes" pageTitle: "_Home_" - roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Student', 'Auditor'] } ) diff --git a/src/app/projects/states/portfolio/portfolio.coffee b/src/app/projects/states/portfolio/portfolio.coffee index 4257ab175..bed3cbd94 100644 --- a/src/app/projects/states/portfolio/portfolio.coffee +++ b/src/app/projects/states/portfolio/portfolio.coffee @@ -14,7 +14,6 @@ angular.module('doubtfire.projects.states.portfolio', [ data: task: "Portfolio Creation" pageTitle: "_Home_" - roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Student', 'Auditor'] } ) diff --git a/src/app/projects/states/project-root-state.component.ts b/src/app/projects/states/project-root-state.component.ts index a8e026d5a..53325cb78 100644 --- a/src/app/projects/states/project-root-state.component.ts +++ b/src/app/projects/states/project-root-state.component.ts @@ -21,7 +21,6 @@ export const ProjectRootState: NgHybridStateDeclaration = { abstract: true, data: { pageTitle: 'Unit Studied', - roleWhiteList: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'], }, views: { main: { diff --git a/src/app/projects/states/tutorials/tutorials.coffee b/src/app/projects/states/tutorials/tutorials.coffee index 06c8d3d53..5c22b609e 100644 --- a/src/app/projects/states/tutorials/tutorials.coffee +++ b/src/app/projects/states/tutorials/tutorials.coffee @@ -12,7 +12,6 @@ angular.module('doubtfire.projects.states.tutorials', []) data: task: "Tutorial List" pageTitle: "_Home_" - roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Student', 'Auditor'] } ) diff --git a/src/app/sessions/transition-hooks.service.ts b/src/app/sessions/transition-hooks.service.ts index 834d0a886..1215c3e6b 100644 --- a/src/app/sessions/transition-hooks.service.ts +++ b/src/app/sessions/transition-hooks.service.ts @@ -4,6 +4,7 @@ import { UserService } from '../api/services/user.service'; import { DoubtfireAngularModule } from '../doubtfire-angular.module'; import { GlobalStateService } from '../projects/states/index/global-state.service'; import { DoubtfireConstants } from '../config/constants/doubtfire-constants'; +import { AuthenticationService } from '../api/services/authentication.service'; /** * The TransitionHooksService is responsible for intercepting transitions between states. @@ -20,7 +21,8 @@ export class TransitionHooksService { private userService: UserService, private transitions: TransitionService, private globalState: GlobalStateService, - private constants: DoubtfireConstants + private constants: DoubtfireConstants, + private authenticationService: AuthenticationService, ) { // Get the tii settings... this.constants.IsTiiEnabled.subscribe((enabled) => { @@ -35,6 +37,7 @@ export class TransitionHooksService { // Where is the transition coming from and going to? const toState = transition.to().name; + const toStateData = transition.to().data; // const fromState = transition.from().name; // Setup the global state @@ -44,6 +47,16 @@ export class TransitionHooksService { this.globalState.setNotInboxState(); } + // Check authorization whitelist + if (toStateData.roleWhitelist && !this.authenticationService.isAuthorised(toStateData.roleWhitelist)) { + if (authenticationService.isAuthenticated()) { + return transition.router.stateService.target("unauthorised"); + } else if (toState !== "sign_in") { + return transition.router.stateService.target("sign_in"); + } + return false; + } + // Adjust settings such as headers switch (toState) { case 'timeout': diff --git a/src/app/units/states/index/index.coffee b/src/app/units/states/index/index.coffee index 88d118d1c..69b9888ea 100644 --- a/src/app/units/states/index/index.coffee +++ b/src/app/units/states/index/index.coffee @@ -13,7 +13,7 @@ angular.module('doubtfire.units.states.index', []) templateUrl: "units/states/index/index.tpl.html" data: pageTitle: "_Home_" - roleWhitelist: ['Student', 'Tutor', 'Convenor', 'Admin', 'Auditor'] + roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor'] } ) diff --git a/src/app/units/states/tasks/inbox/inbox.coffee b/src/app/units/states/tasks/inbox/inbox.coffee index 9f04950ca..1be954676 100644 --- a/src/app/units/states/tasks/inbox/inbox.coffee +++ b/src/app/units/states/tasks/inbox/inbox.coffee @@ -14,7 +14,7 @@ angular.module('doubtfire.units.states.tasks.inbox', []) data: task: "Task Inbox" pageTitle: "_Home_" - roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor', 'Auditor'] + roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor'] } ) diff --git a/src/app/units/task-viewer/task-viewer-state.component.ts b/src/app/units/task-viewer/task-viewer-state.component.ts index 833647f4c..08fdcf38a 100644 --- a/src/app/units/task-viewer/task-viewer-state.component.ts +++ b/src/app/units/task-viewer/task-viewer-state.component.ts @@ -39,7 +39,7 @@ export const TaskViewerState: NgHybridStateDeclaration = { parent: 'unit-root-state', data: { pageTitle: 'Unit Tasks', - roleWhiteList: ['Tutor', 'Convenor', 'Admin', 'Auditor'], + roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor'], }, views: { unitView: { diff --git a/src/app/units/unit-root-state.component.ts b/src/app/units/unit-root-state.component.ts index 8a6109121..cd239a61a 100644 --- a/src/app/units/unit-root-state.component.ts +++ b/src/app/units/unit-root-state.component.ts @@ -34,7 +34,7 @@ export const UnitRootState: NgHybridStateDeclaration = { abstract: true, data: { pageTitle: 'Unit Root State', - roleWhiteList: ['Tutor', 'Convenor', 'Admin', 'Auditor'], + roleWhitelist: ['Tutor', 'Convenor', 'Admin', 'Auditor'], }, views: { main: {