Fix process cloud page (#4075)

* Fix process cloud page

* Use FilterParamModel

* Rollback method

* Fix core unit test related to identity service

* Fix process filters cloud
Get user info from different keys

* Select the my-task filter in case the task has been created

* Add family_name and given_name to the jwt token
This commit is contained in:
Maurizio Vitale
2018-12-12 15:43:57 +00:00
committed by Eugenio Romano
parent 511087f6b1
commit e241779f3a
29 changed files with 261 additions and 240 deletions

View File

@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { of, Observable, from } from 'rxjs';
import { Observable, from } from 'rxjs';
import { map } from 'rxjs/operators';
import { IdentityUserModel } from '../models/identity-user.model';
@@ -31,6 +31,8 @@ import { IdentityRoleModel } from '../models/identity-role.model';
export class IdentityUserService {
static USER_NAME = 'name';
static FAMILY_NAME = 'family_name';
static GIVEN_NAME = 'given_name';
static USER_EMAIL = 'email';
static USER_ACCESS_TOKEN = 'access_token';
static USER_PREFERRED_USERNAME = 'preferred_username';
@@ -40,13 +42,13 @@ export class IdentityUserService {
private apiService: AlfrescoApiService,
private appConfigService: AppConfigService) {}
getCurrentUserInfo(): Observable<IdentityUserModel> {
const fullName = this.getValueFromToken<string>(IdentityUserService.USER_NAME);
getCurrentUserInfo(): IdentityUserModel {
const familyName = this.getValueFromToken<string>(IdentityUserService.FAMILY_NAME);
const givenName = this.getValueFromToken<string>(IdentityUserService.GIVEN_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, username: username };
return of(new IdentityUserModel(user));
const user = { firstName: givenName, lastName: familyName, email: email, username: username };
return new IdentityUserModel(user);
}
getValueFromToken<T>(key: string): T {
@@ -110,7 +112,7 @@ export class IdentityUserService {
async getUsersByRolesWithoutCurrentUser(roleNames: string[]): Promise<IdentityUserModel[]> {
const filteredUsers: IdentityUserModel[] = [];
if (roleNames && roleNames.length > 0) {
const currentUser = await this.getCurrentUserInfo().toPromise();
const currentUser = this.getCurrentUserInfo();
let users = await this.getUsers().toPromise();
users = users.filter((user) => { return user.username !== currentUser.username; });