Skip to content

Commit

Permalink
Merge a6b2ed6 into 01231ef
Browse files Browse the repository at this point in the history
  • Loading branch information
atarix83 committed Mar 3, 2020
2 parents 01231ef + a6b2ed6 commit 6b309a9
Show file tree
Hide file tree
Showing 47 changed files with 1,693 additions and 408 deletions.
4 changes: 4 additions & 0 deletions resources/i18n/en.json5
Expand Up @@ -1083,8 +1083,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
16 changes: 13 additions & 3 deletions src/app/app-routing.module.ts
Expand Up @@ -59,15 +59,25 @@ export function getDSOPath(dso: DSpaceObject): string {
{ 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 @@ -10,6 +10,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 @@ -18,7 +19,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 @@ -38,7 +40,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 @@ -67,4 +69,5 @@ export class AuthRequestService {
mergeMap((request: GetRequest) => this.fetchRequest(request)),
distinctUntilChanged());
}

}
94 changes: 80 additions & 14 deletions src/app/core/auth/auth.actions.ts
Expand Up @@ -5,6 +5,8 @@ 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 @@ -14,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 Down Expand Up @@ -95,7 +101,7 @@ export class AuthenticatedErrorAction implements Action {
payload: Error;

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

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

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

Expand Down Expand Up @@ -138,11 +144,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 @@ -152,7 +158,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 @@ -165,7 +173,7 @@ export class LogOutErrorAction implements Action {
payload: Error;

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

Expand All @@ -176,7 +184,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 @@ -189,7 +199,7 @@ export class RedirectWhenAuthenticationIsRequiredAction implements Action {
payload: string;

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

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

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

Expand Down Expand Up @@ -244,6 +254,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 @@ -268,7 +287,7 @@ export class RegistrationErrorAction implements Action {
payload: Error;

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

Expand Down Expand Up @@ -309,6 +328,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 @@ -319,7 +377,7 @@ export class SetRedirectUrlAction implements Action {
payload: string;

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

Expand Down Expand Up @@ -378,13 +436,21 @@ export type AuthActions
| AuthenticationErrorAction
| AuthenticationSuccessAction
| CheckAuthenticationTokenAction
| CheckAuthenticationTokenErrorAction
| CheckAuthenticationTokenCookieAction
| RedirectWhenAuthenticationIsRequiredAction
| RedirectWhenTokenExpiredAction
| RegistrationAction
| RegistrationErrorAction
| RegistrationSuccessAction
| AddAuthenticationMessageAction
| RefreshTokenAction
| RefreshTokenErrorAction
| RefreshTokenSuccessAction
| ResetAuthenticationMessagesAction
| RetrieveAuthMethodsAction
| RetrieveAuthMethodsSuccessAction
| RetrieveAuthMethodsErrorAction
| RetrieveTokenAction
| ResetAuthenticationMessagesAction
| RetrieveAuthenticatedEpersonAction
| RetrieveAuthenticatedEpersonErrorAction
Expand Down

0 comments on commit 6b309a9

Please sign in to comment.