Skip to content

Commit

Permalink
Merge 1a192ec into a6f1a6d
Browse files Browse the repository at this point in the history
  • Loading branch information
atarix83 committed Feb 25, 2020
2 parents a6f1a6d + 1a192ec commit 43ec077
Show file tree
Hide file tree
Showing 47 changed files with 1,643 additions and 358 deletions.
4 changes: 4 additions & 0 deletions resources/i18n/en.json5
Expand Up @@ -1071,8 +1071,12 @@

"login.form.new-user": "New user? Click here to register.",

"login.form.or-divider": "or",

"login.form.password": "Password",

"login.form.shibboleth": "Log in with Shibboleth",

"login.form.submit": "Log in",

"login.title": "Login",
Expand Down
24 changes: 20 additions & 4 deletions src/app/app-routing.module.ts
Expand Up @@ -5,19 +5,25 @@ import { PageNotFoundComponent } from './pagenotfound/pagenotfound.component';
import { AuthenticatedGuard } from './core/auth/authenticated.guard';

const ITEM_MODULE_PATH = 'items';

export function getItemModulePath() {
return `/${ITEM_MODULE_PATH}`;
}

const COLLECTION_MODULE_PATH = 'collections';

export function getCollectionModulePath() {
return `/${COLLECTION_MODULE_PATH}`;
}

const COMMUNITY_MODULE_PATH = 'communities';

export function getCommunityModulePath() {
return `/${COMMUNITY_MODULE_PATH}`;
}

const ADMIN_MODULE_PATH = 'admin';
const ADMIN_MODULE_PATH = 'admin';

export function getAdminModulePath() {
return `/${ADMIN_MODULE_PATH}`;
}
Expand All @@ -33,15 +39,25 @@ export function getAdminModulePath() {
{ path: COMMUNITY_MODULE_PATH, loadChildren: './+community-page/community-page.module#CommunityPageModule' },
{ path: COLLECTION_MODULE_PATH, loadChildren: './+collection-page/collection-page.module#CollectionPageModule' },
{ path: ITEM_MODULE_PATH, loadChildren: './+item-page/item-page.module#ItemPageModule' },
{ path: 'mydspace', loadChildren: './+my-dspace-page/my-dspace-page.module#MyDSpacePageModule', canActivate: [AuthenticatedGuard] },
{
path: 'mydspace',
loadChildren: './+my-dspace-page/my-dspace-page.module#MyDSpacePageModule',
canActivate: [AuthenticatedGuard]
},
{ path: 'search', loadChildren: './+search-page/search-page.module#SearchPageModule' },
{ path: 'browse', loadChildren: './+browse-by/browse-by.module#BrowseByModule' },
{ path: ADMIN_MODULE_PATH, loadChildren: './+admin/admin.module#AdminModule', canActivate: [AuthenticatedGuard] },
{ path: 'login', loadChildren: './+login-page/login-page.module#LoginPageModule' },
{ path: 'logout', loadChildren: './+logout-page/logout-page.module#LogoutPageModule' },
{ path: 'submit', loadChildren: './+submit-page/submit-page.module#SubmitPageModule' },
{ path: 'workspaceitems', loadChildren: './+workspaceitems-edit-page/workspaceitems-edit-page.module#WorkspaceitemsEditPageModule' },
{ path: 'workflowitems', loadChildren: './+workflowitems-edit-page/workflowitems-edit-page.module#WorkflowItemsEditPageModule' },
{
path: 'workspaceitems',
loadChildren: './+workspaceitems-edit-page/workspaceitems-edit-page.module#WorkspaceitemsEditPageModule'
},
{
path: 'workflowitems',
loadChildren: './+workflowitems-edit-page/workflowitems-edit-page.module#WorkflowItemsEditPageModule'
},
{ path: '**', pathMatch: 'full', component: PageNotFoundComponent },
])
],
Expand Down
7 changes: 5 additions & 2 deletions src/app/core/auth/auth-request.service.ts
Expand Up @@ -11,6 +11,7 @@ import { AuthGetRequest, AuthPostRequest, GetRequest, PostRequest, RestRequest }
import { AuthStatusResponse, ErrorResponse } from '../cache/response.models';
import { HttpOptions } from '../dspace-rest-v2/dspace-rest-v2.service';
import { getResponseFromEntry } from '../shared/operators';
import { HttpClient } from '@angular/common/http';

@Injectable()
export class AuthRequestService {
Expand All @@ -19,7 +20,8 @@ export class AuthRequestService {

constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
protected halService: HALEndpointService,
protected requestService: RequestService) {
protected requestService: RequestService,
private http: HttpClient) {
}

protected fetchRequest(request: RestRequest): Observable<any> {
Expand All @@ -39,7 +41,7 @@ export class AuthRequestService {
return isNotEmpty(method) ? `${endpoint}/${method}` : `${endpoint}`;
}

public postToEndpoint(method: string, body: any, options?: HttpOptions): Observable<any> {
public postToEndpoint(method: string, body?: any, options?: HttpOptions): Observable<any> {
return this.halService.getEndpoint(this.linkName).pipe(
filter((href: string) => isNotEmpty(href)),
map((endpointURL) => this.getEndpointByMethod(endpointURL, method)),
Expand Down Expand Up @@ -68,4 +70,5 @@ export class AuthRequestService {
mergeMap((request: GetRequest) => this.fetchRequest(request)),
distinctUntilChanged());
}

}
101 changes: 82 additions & 19 deletions src/app/core/auth/auth.actions.ts
@@ -1,12 +1,12 @@
// import @ngrx
import { Action } from '@ngrx/store';

// import type function
import { type } from '../../shared/ngrx/type';

// import models
import { EPerson } from '../eperson/models/eperson.model';
import { AuthTokenInfo } from './models/auth-token-info.model';
import { AuthMethod } from './models/auth.method';
import { AuthStatus } from './models/auth-status.model';

export const AuthActionTypes = {
AUTHENTICATE: type('dspace/auth/AUTHENTICATE'),
Expand All @@ -16,12 +16,16 @@ export const AuthActionTypes = {
AUTHENTICATED_ERROR: type('dspace/auth/AUTHENTICATED_ERROR'),
AUTHENTICATED_SUCCESS: type('dspace/auth/AUTHENTICATED_SUCCESS'),
CHECK_AUTHENTICATION_TOKEN: type('dspace/auth/CHECK_AUTHENTICATION_TOKEN'),
CHECK_AUTHENTICATION_TOKEN_ERROR: type('dspace/auth/CHECK_AUTHENTICATION_TOKEN_ERROR'),
CHECK_AUTHENTICATION_TOKEN_COOKIE: type('dspace/auth/CHECK_AUTHENTICATION_TOKEN_COOKIE'),
RETRIEVE_AUTH_METHODS: type('dspace/auth/RETRIEVE_AUTH_METHODS'),
RETRIEVE_AUTH_METHODS_SUCCESS: type('dspace/auth/RETRIEVE_AUTH_METHODS_SUCCESS'),
RETRIEVE_AUTH_METHODS_ERROR: type('dspace/auth/RETRIEVE_AUTH_METHODS_ERROR'),
REDIRECT_TOKEN_EXPIRED: type('dspace/auth/REDIRECT_TOKEN_EXPIRED'),
REDIRECT_AUTHENTICATION_REQUIRED: type('dspace/auth/REDIRECT_AUTHENTICATION_REQUIRED'),
REFRESH_TOKEN: type('dspace/auth/REFRESH_TOKEN'),
REFRESH_TOKEN_SUCCESS: type('dspace/auth/REFRESH_TOKEN_SUCCESS'),
REFRESH_TOKEN_ERROR: type('dspace/auth/REFRESH_TOKEN_ERROR'),
RETRIEVE_TOKEN: type('dspace/auth/RETRIEVE_TOKEN'),
ADD_MESSAGE: type('dspace/auth/ADD_MESSAGE'),
RESET_MESSAGES: type('dspace/auth/RESET_MESSAGES'),
LOG_OUT: type('dspace/auth/LOG_OUT'),
Expand All @@ -48,7 +52,7 @@ export class AuthenticateAction implements Action {
};

constructor(email: string, password: string) {
this.payload = { email, password };
this.payload = {email, password};
}
}

Expand Down Expand Up @@ -80,7 +84,7 @@ export class AuthenticatedSuccessAction implements Action {
};

constructor(authenticated: boolean, authToken: AuthTokenInfo, user: EPerson) {
this.payload = { authenticated, authToken, user };
this.payload = {authenticated, authToken, user};
}
}

Expand All @@ -94,7 +98,7 @@ export class AuthenticatedErrorAction implements Action {
payload: Error;

constructor(payload: Error) {
this.payload = payload ;
this.payload = payload;
}
}

Expand All @@ -108,7 +112,7 @@ export class AuthenticationErrorAction implements Action {
payload: Error;

constructor(payload: Error) {
this.payload = payload ;
this.payload = payload;
}
}

Expand Down Expand Up @@ -137,11 +141,11 @@ export class CheckAuthenticationTokenAction implements Action {

/**
* Check Authentication Token Error.
* @class CheckAuthenticationTokenErrorAction
* @class CheckAuthenticationTokenCookieAction
* @implements {Action}
*/
export class CheckAuthenticationTokenErrorAction implements Action {
public type: string = AuthActionTypes.CHECK_AUTHENTICATION_TOKEN_ERROR;
export class CheckAuthenticationTokenCookieAction implements Action {
public type: string = AuthActionTypes.CHECK_AUTHENTICATION_TOKEN_COOKIE;
}

/**
Expand All @@ -151,7 +155,9 @@ export class CheckAuthenticationTokenErrorAction implements Action {
*/
export class LogOutAction implements Action {
public type: string = AuthActionTypes.LOG_OUT;
constructor(public payload?: any) {}

constructor(public payload?: any) {
}
}

/**
Expand All @@ -164,7 +170,7 @@ export class LogOutErrorAction implements Action {
payload: Error;

constructor(payload: Error) {
this.payload = payload ;
this.payload = payload;
}
}

Expand All @@ -175,7 +181,9 @@ export class LogOutErrorAction implements Action {
*/
export class LogOutSuccessAction implements Action {
public type: string = AuthActionTypes.LOG_OUT_SUCCESS;
constructor(public payload?: any) {}

constructor(public payload?: any) {
}
}

/**
Expand All @@ -188,7 +196,7 @@ export class RedirectWhenAuthenticationIsRequiredAction implements Action {
payload: string;

constructor(message: string) {
this.payload = message ;
this.payload = message;
}
}

Expand All @@ -202,7 +210,7 @@ export class RedirectWhenTokenExpiredAction implements Action {
payload: string;

constructor(message: string) {
this.payload = message ;
this.payload = message;
}
}

Expand Down Expand Up @@ -243,6 +251,15 @@ export class RefreshTokenErrorAction implements Action {
public type: string = AuthActionTypes.REFRESH_TOKEN_ERROR;
}

/**
* Retrieve authentication token.
* @class RetrieveTokenAction
* @implements {Action}
*/
export class RetrieveTokenAction implements Action {
public type: string = AuthActionTypes.RETRIEVE_TOKEN;
}

/**
* Sign up.
* @class RegistrationAction
Expand All @@ -267,7 +284,7 @@ export class RegistrationErrorAction implements Action {
payload: Error;

constructor(payload: Error) {
this.payload = payload ;
this.payload = payload;
}
}

Expand Down Expand Up @@ -308,6 +325,45 @@ export class ResetAuthenticationMessagesAction implements Action {
public type: string = AuthActionTypes.RESET_MESSAGES;
}

// // Next three Actions are used by dynamic login methods
/**
* Action that triggers an effect fetching the authentication methods enabled ant the backend
* @class RetrieveAuthMethodsAction
* @implements {Action}
*/
export class RetrieveAuthMethodsAction implements Action {
public type: string = AuthActionTypes.RETRIEVE_AUTH_METHODS;

payload: AuthStatus;

constructor(authStatus: AuthStatus) {
this.payload = authStatus;
}
}

/**
* Get Authentication methods enabled at the backend
* @class RetrieveAuthMethodsSuccessAction
* @implements {Action}
*/
export class RetrieveAuthMethodsSuccessAction implements Action {
public type: string = AuthActionTypes.RETRIEVE_AUTH_METHODS_SUCCESS;
payload: AuthMethod[];

constructor(authMethods: AuthMethod[] ) {
this.payload = authMethods;
}
}

/**
* Set password as default authentication method on error
* @class RetrieveAuthMethodsErrorAction
* @implements {Action}
*/
export class RetrieveAuthMethodsErrorAction implements Action {
public type: string = AuthActionTypes.RETRIEVE_AUTH_METHODS_ERROR;
}

/**
* Change the redirect url.
* @class SetRedirectUrlAction
Expand All @@ -318,7 +374,7 @@ export class SetRedirectUrlAction implements Action {
payload: string;

constructor(url: string) {
this.payload = url ;
this.payload = url;
}
}

Expand All @@ -336,11 +392,18 @@ export type AuthActions
| AuthenticationErrorAction
| AuthenticationSuccessAction
| CheckAuthenticationTokenAction
| CheckAuthenticationTokenErrorAction
| CheckAuthenticationTokenCookieAction
| RedirectWhenAuthenticationIsRequiredAction
| RedirectWhenTokenExpiredAction
| RegistrationAction
| RegistrationErrorAction
| RegistrationSuccessAction
| AddAuthenticationMessageAction
| ResetAuthenticationMessagesAction;
| RefreshTokenAction
| RefreshTokenErrorAction
| RefreshTokenSuccessAction
| ResetAuthenticationMessagesAction
| RetrieveAuthMethodsAction
| RetrieveAuthMethodsSuccessAction
| RetrieveAuthMethodsErrorAction
| RetrieveTokenAction;

0 comments on commit 43ec077

Please sign in to comment.