From 2c5dc4ac8543bffd533e1114bb1937c36915c7a0 Mon Sep 17 00:00:00 2001 From: Andrew Wilson Date: Thu, 14 Mar 2024 10:44:21 +0000 Subject: [PATCH] gh-375 - return the sde user details rather than the mdm user details. --- .../configuration/sde-security.ts | 19 ++++--------------- src/app/security/user-details.service.ts | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/app/secure-data-environment/configuration/sde-security.ts b/src/app/secure-data-environment/configuration/sde-security.ts index ee24942b..63429e55 100644 --- a/src/app/secure-data-environment/configuration/sde-security.ts +++ b/src/app/secure-data-environment/configuration/sde-security.ts @@ -17,25 +17,14 @@ limitations under the License. SPDX-License-Identifier: Apache-2.0 */ import { Injectable } from '@angular/core'; -import { ISdeSecurity, SignedInUserDetails } from '@maurodatamapper/sde-resources'; +import { ISdeSecurity, SdeUserDetails } from '@maurodatamapper/sde-resources'; import { UserDetailsService } from 'src/app/security/user-details.service'; @Injectable({ providedIn: 'root' }) export class SdeSecurity implements ISdeSecurity { - constructor(private userDetails: UserDetailsService) {} + constructor(private userDetails: UserDetailsService) { } - getSignedInUser() { - const securityDetails = this.userDetails.get(); - if (securityDetails) { - return { - id: securityDetails.id, - firstName: securityDetails.firstName, - lastName: securityDetails.lastName, - email: securityDetails.email, - role: securityDetails.role, - token: securityDetails.sdeAuthToken, - } as SignedInUserDetails; - } - return null; + getSignedInUser(): SdeUserDetails | null { + return this.userDetails.getSdeResearchUser(); } } diff --git a/src/app/security/user-details.service.ts b/src/app/security/user-details.service.ts index 4781ae14..8d870431 100644 --- a/src/app/security/user-details.service.ts +++ b/src/app/security/user-details.service.ts @@ -18,7 +18,7 @@ SPDX-License-Identifier: Apache-2.0 */ import { Injectable } from '@angular/core'; import { FolderDetail } from '@maurodatamapper/mdm-resources'; -import { ResearchUser } from '@maurodatamapper/sde-resources'; +import { ResearchUser, SdeUserDetails } from '@maurodatamapper/sde-resources'; /** * Represents the common details of a signed in user. @@ -44,7 +44,7 @@ export interface UserDetails { providedIn: 'root', }) export class UserDetailsService { - constructor() {} + constructor() { } /** * Gets the current user in use, or null if there is no current user. @@ -107,6 +107,20 @@ export class UserDetailsService { localStorage.removeItem('sdeAuthToken'); } + getSdeResearchUser(): SdeUserDetails | null { + if (!this.hasSdeResearchUser()) { + return null; + } + + return { + id: localStorage.getItem('sdeUserId') ?? '', + email: localStorage.getItem('sdeEmail') ?? '', + firstName: localStorage.getItem('firstName') ?? '', + lastName: localStorage.getItem('lastName') ?? '', + role: localStorage.getItem('role') ?? '', + } as SdeUserDetails; + } + setSdeResearchUser(user: ResearchUser) { localStorage.setItem('sdeUserId', user.id); localStorage.setItem('sdeEmail', user.email);