mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3540] Start Task Cloud by cli - Core module changes (#4006)
* [ADF-3540] Added username and id to the usermodel * [ADF-3540] Added tests
This commit is contained in:
committed by
Maurizio Vitale
parent
34a30c0f14
commit
74851ac651
@@ -15,8 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export let mockToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.'
|
||||
+ 'eyJzdWIiOiIxMjM0NTY3ODkwIiwiZW1haWwiOiJqb2huRG9lQGdtYWlsLmNvbSI'
|
||||
+ 'sImdpdmVuX25hbWUiOiJKb2huIERvZSIsImp0aSI6IjY1ZGMzZTEyLWJhNGUtNDQ'
|
||||
+ '2Mi1iZjAyLTBlZGQ2MTYwM2M2NCIsImlhdCI6MTU0MjcyMTYxMywiZXhwIjoxNTQyNzI3NzY5fQ'
|
||||
+ '.cUxMzfiJeLwh9Er2CBn_y8ehQgSm_s2-NHehx-SRZKg';
|
||||
export let mockToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIx' +
|
||||
'MjM0NTY3ODkwIiwiZW1haWwiOiJqb2huRG9lQGdtYWlsLmNvbSIsImdpdmVuX25h' +
|
||||
'bWUiOiJKb2huIERvZSIsInByZWZlcnJlZF91c2VybmFtZSI6ImpvaG5Eb2UxIiwi' +
|
||||
'anRpIjoiNjVkYzNlMTItYmE0ZS00NDYyLWJmMDItMGVkZDYxNjAzYzY0IiwiaWF0' +
|
||||
'IjoxNTQyNzIxNjEzLCJleHAiOjE1NDI3Mjc3Njl9.W-KUqsy5IBVgG0RhZTvTUXY' +
|
||||
'1no5wE9lghKXGFNgFbuA';
|
||||
|
@@ -17,15 +17,19 @@
|
||||
|
||||
export class IdentityUserModel {
|
||||
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
email: string;
|
||||
username: string;
|
||||
|
||||
constructor(obj?: any) {
|
||||
if (obj) {
|
||||
this.id = obj.id || null;
|
||||
this.firstName = obj.firstName || null;
|
||||
this.lastName = obj.lastName || null;
|
||||
this.email = obj.email || null;
|
||||
this.username = obj.username || null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -54,6 +54,7 @@ describe('IdentityUserService', () => {
|
||||
expect(user.firstName).toEqual('John');
|
||||
expect(user.lastName).toEqual('Doe');
|
||||
expect(user.email).toEqual('johnDoe@gmail.com');
|
||||
expect(user.username).toEqual('johnDoe1');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@@ -28,14 +28,16 @@ export class IdentityUserService {
|
||||
static USER_NAME = 'given_name';
|
||||
static USER_EMAIL = 'email';
|
||||
static USER_ACCESS_TOKEN = 'access_token';
|
||||
static USER_PREFERRED_USERNAME = 'preferred_username';
|
||||
|
||||
constructor(private helper: JwtHelperService) {}
|
||||
|
||||
getCurrentUserInfo(): Observable<IdentityUserModel> {
|
||||
const fullName = this.getValueFromToken<string>(IdentityUserService.USER_NAME);
|
||||
const email = this.getValueFromToken<string>(IdentityUserService.USER_EMAIL);
|
||||
const username = this.getValueFromToken<string>(IdentityUserService.USER_PREFERRED_USERNAME);
|
||||
const nameParts = fullName.split(' ');
|
||||
const user = { firstName: nameParts[0], lastName: nameParts[1], email: email };
|
||||
const user = { firstName: nameParts[0], lastName: nameParts[1], email: email, username: username };
|
||||
return of(new IdentityUserModel(user));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user