Skip to content
Snippets Groups Projects
Commit 3f084a97 authored by François Agneray's avatar François Agneray
Browse files

Add open edit profile

parent 18d57ebc
No related branches found
No related tags found
2 merge requests!169Develop,!160Resolve "Intégrer l'authentification avec keycloak"
...@@ -4,6 +4,7 @@ export const LOGIN = '[Auth] Login'; ...@@ -4,6 +4,7 @@ export const LOGIN = '[Auth] Login';
export const LOGOUT = '[Auth] Logout'; export const LOGOUT = '[Auth] Logout';
export const AUTH_SUCCESS = '[Auth] Auth Success'; export const AUTH_SUCCESS = '[Auth] Auth Success';
export const LOAD_USER_PROFILE_SUCCESS = '[Auth] Load User Profile Success'; export const LOAD_USER_PROFILE_SUCCESS = '[Auth] Load User Profile Success';
export const OPEN_EDIT_PROFILE = '[Auth] Edit Profile';
export class LoginAction implements Action { export class LoginAction implements Action {
readonly type = LOGIN; readonly type = LOGIN;
...@@ -29,8 +30,15 @@ export class LoadUserProfileSuccessAction implements Action { ...@@ -29,8 +30,15 @@ export class LoadUserProfileSuccessAction implements Action {
constructor(public payload: Keycloak.KeycloakProfile) { } constructor(public payload: Keycloak.KeycloakProfile) { }
} }
export class OpenEditProfileAction implements Action {
readonly type = OPEN_EDIT_PROFILE;
constructor(public payload: {} = null) { }
}
export type Actions export type Actions
= LoginAction = LoginAction
| LogoutAction | LogoutAction
| AuthSuccessAction | AuthSuccessAction
| LoadUserProfileSuccessAction; | LoadUserProfileSuccessAction
| OpenEditProfileAction;
...@@ -6,6 +6,7 @@ import { Effect, Actions, ofType } from '@ngrx/effects'; ...@@ -6,6 +6,7 @@ import { Effect, Actions, ofType } from '@ngrx/effects';
import { KeycloakService } from 'keycloak-angular'; import { KeycloakService } from 'keycloak-angular';
import * as authActions from './auth.action'; import * as authActions from './auth.action';
import { environment } from '../../../environments/environment';
@Injectable() @Injectable()
export class AuthEffects { export class AuthEffects {
...@@ -35,4 +36,10 @@ export class AuthEffects { ...@@ -35,4 +36,10 @@ export class AuthEffects {
) )
) )
); );
@Effect({ dispatch: false })
OpenEditProfileAction$ = this.actions$.pipe(
ofType(authActions.OPEN_EDIT_PROFILE),
tap(_ => window.open(environment.ssoAuthUrl + '/realms/' + environment.ssoRealm + '/account', '_blank'))
);
} }
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
</li> </li>
<li class="divider dropdown-divider"></li> <li class="divider dropdown-divider"></li>
<li role="menuitem"> <li role="menuitem">
<a class="dropdown-item" routerLink="/change-password"> <a class="dropdown-item pointer" (click)="emitOpenEditProfile()">
<span class="fas fa-key fa-fw"></span> Change password <span class="fas fa-id-card"></span> Edit profile
</a> </a>
</li> </li>
<li class="divider dropdown-divider"></li> <li class="divider dropdown-divider"></li>
...@@ -96,8 +96,8 @@ ...@@ -96,8 +96,8 @@
</li> </li>
<li *ngIf="isAuthenticated" class="divider dropdown-divider"></li> <li *ngIf="isAuthenticated" class="divider dropdown-divider"></li>
<li *ngIf="isAuthenticated" role="menuitem"> <li *ngIf="isAuthenticated" role="menuitem">
<a class="dropdown-item" routerLink="/change-password"> <a class="dropdown-item pointer" (click)="emitOpenEditProfile()">
<span class="fas fa-key fa-fw"></span> Change password <span class="fas fa-id-card"></span> Edit profile
</a> </a>
</li> </li>
<li class="divider dropdown-divider"></li> <li class="divider dropdown-divider"></li>
......
...@@ -15,6 +15,7 @@ export class NavComponent { ...@@ -15,6 +15,7 @@ export class NavComponent {
@Input() instance: Instance; @Input() instance: Instance;
@Output() login: EventEmitter<any> = new EventEmitter(); @Output() login: EventEmitter<any> = new EventEmitter();
@Output() logout: EventEmitter<any> = new EventEmitter(); @Output() logout: EventEmitter<any> = new EventEmitter();
@Output() openEditProfile: EventEmitter<any> = new EventEmitter();
baseHref: string = environment.baseHref; baseHref: string = environment.baseHref;
isSearchAllowed(): boolean { isSearchAllowed(): boolean {
...@@ -45,4 +46,8 @@ export class NavComponent { ...@@ -45,4 +46,8 @@ export class NavComponent {
emitLogout() { emitLogout() {
this.logout.emit(); this.logout.emit();
} }
emitOpenEditProfile() {
this.openEditProfile.emit();
}
} }
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
[userProfile]="userProfile | async" [userProfile]="userProfile | async"
[instance]="instance | async" [instance]="instance | async"
(login)="login()" (login)="login()"
(logout)="logout()"> (logout)="logout()"
(openEditProfile)="openEditProfile()">
</app-nav> </app-nav>
</header> </header>
<main role="main" class="container-fluid pb-4"> <main role="main" class="container-fluid pb-4">
......
...@@ -47,4 +47,8 @@ export class AppComponent implements OnInit { ...@@ -47,4 +47,8 @@ export class AppComponent implements OnInit {
logout(): void { logout(): void {
this.store.dispatch(new authActions.LogoutAction()); this.store.dispatch(new authActions.LogoutAction());
} }
openEditProfile(): void {
this.store.dispatch(new authActions.OpenEditProfileAction());
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment