mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2876] retrieving user from APS api and not from js-api (#3426)
* [ADF-2876] retrieving user from APS api and not from js-api * [ADF-2876] added support by checking externalId instead of email * [ADF-2876] fixed auth service after rebase
This commit is contained in:
@@ -27,6 +27,7 @@ export class UserProcessModel implements LightUserRepresentation {
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
pictureId?: number = null;
|
||||
externalId?: string;
|
||||
|
||||
constructor(obj?: any) {
|
||||
if (obj) {
|
||||
@@ -35,6 +36,7 @@ export class UserProcessModel implements LightUserRepresentation {
|
||||
this.firstName = obj.firstName || null;
|
||||
this.lastName = obj.lastName || null;
|
||||
this.pictureId = obj.pictureId || null;
|
||||
this.externalId = obj.externalId || null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,7 @@ import { CookieService } from './cookie.service';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { UserRepresentation } from 'alfresco-js-api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -349,6 +350,18 @@ describe('AuthenticationService', () => {
|
||||
it('[BPM] should return isALLProvider false', () => {
|
||||
expect(authService.isALLProvider()).toBe(false);
|
||||
});
|
||||
|
||||
it('[BPM] should be able to retrieve current logged in user', (done) => {
|
||||
spyOn(apiService.getInstance().activiti.profileApi, 'getProfile').and.returnValue(
|
||||
Promise.resolve((<UserRepresentation> {
|
||||
email: 'fake-email'
|
||||
})));
|
||||
|
||||
authService.getBpmLoggedUser().subscribe((fakeUser) => {
|
||||
expect(fakeUser.email).toBe('fake-email');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the setting is both ECM and BPM ', () => {
|
||||
|
@@ -26,6 +26,7 @@ import { AppConfigService, AppConfigValues } from '../app-config/app-config.serv
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { UserRepresentation } from 'alfresco-js-api';
|
||||
|
||||
const REMEMBER_ME_COOKIE_KEY = 'ALFRESCO_REMEMBER_ME';
|
||||
const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30 ;
|
||||
@@ -228,6 +229,10 @@ export class AuthenticationService {
|
||||
return this.hasValidRedirection(provider) ? this.redirectUrl.url : null;
|
||||
}
|
||||
|
||||
getBpmLoggedUser(): Observable<UserRepresentation> {
|
||||
return Observable.fromPromise(this.alfrescoApi.getInstance().activiti.profileApi.getProfile());
|
||||
}
|
||||
|
||||
private hasValidRedirection(provider: string): boolean {
|
||||
return this.redirectUrl && (this.redirectUrl.provider === provider || this.hasSelectedProviderAll(provider));
|
||||
}
|
||||
|
Reference in New Issue
Block a user