mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
fix eslint warnigs for core project (#7506)
This commit is contained in:
@@ -46,6 +46,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Gets the name and other basic details of the current user.
|
||||
*
|
||||
* @returns The user's details
|
||||
*/
|
||||
getCurrentUserInfo(): IdentityUserModel {
|
||||
@@ -53,11 +54,12 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
const givenName = this.jwtHelperService.getValueFromLocalToken<string>(JwtHelperService.GIVEN_NAME);
|
||||
const email = this.jwtHelperService.getValueFromLocalToken<string>(JwtHelperService.USER_EMAIL);
|
||||
const username = this.jwtHelperService.getValueFromLocalToken<string>(JwtHelperService.USER_PREFERRED_USERNAME);
|
||||
return { firstName: givenName, lastName: familyName, email: email, username: username };
|
||||
return { firstName: givenName, lastName: familyName, email, username };
|
||||
}
|
||||
|
||||
/**
|
||||
* Find users based on search input.
|
||||
*
|
||||
* @param search Search query string
|
||||
* @returns List of users
|
||||
*/
|
||||
@@ -66,13 +68,14 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
return of([]);
|
||||
}
|
||||
const url = this.buildUserUrl();
|
||||
const queryParams = { search: search };
|
||||
const queryParams = { search };
|
||||
|
||||
return this.oAuth2Service.get({ url, queryParams });
|
||||
}
|
||||
|
||||
/**
|
||||
* Find users based on username input.
|
||||
*
|
||||
* @param username Search query string
|
||||
* @returns List of users
|
||||
*/
|
||||
@@ -81,13 +84,14 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
return of([]);
|
||||
}
|
||||
const url = this.buildUserUrl();
|
||||
const queryParams = { username: username };
|
||||
const queryParams = { username };
|
||||
|
||||
return this.oAuth2Service.get({url, queryParams });
|
||||
}
|
||||
|
||||
/**
|
||||
* Find users based on email input.
|
||||
*
|
||||
* @param email Search query string
|
||||
* @returns List of users
|
||||
*/
|
||||
@@ -96,13 +100,14 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
return of([]);
|
||||
}
|
||||
const url = this.buildUserUrl();
|
||||
const queryParams = { email: email };
|
||||
const queryParams = { email };
|
||||
|
||||
return this.oAuth2Service.get({ url, queryParams });
|
||||
}
|
||||
|
||||
/**
|
||||
* Find users based on id input.
|
||||
*
|
||||
* @param id Search query string
|
||||
* @returns users object
|
||||
*/
|
||||
@@ -116,6 +121,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Get client roles of a user for a particular client.
|
||||
*
|
||||
* @param userId ID of the target user
|
||||
* @param clientId ID of the client app
|
||||
* @returns List of client roles
|
||||
@@ -127,6 +133,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Checks whether user has access to a client app.
|
||||
*
|
||||
* @param userId ID of the target user
|
||||
* @param clientId ID of the client app
|
||||
* @returns True if the user has access, false otherwise
|
||||
@@ -139,6 +146,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Checks whether a user has any of the client app roles.
|
||||
*
|
||||
* @param userId ID of the target user
|
||||
* @param clientId ID of the client app
|
||||
* @param roleNames List of role names to check for
|
||||
@@ -165,6 +173,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Gets the client ID for an application.
|
||||
*
|
||||
* @param applicationName Name of the application
|
||||
* @returns Client ID string
|
||||
*/
|
||||
@@ -181,20 +190,20 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Checks if a user has access to an application.
|
||||
*
|
||||
* @param userId ID of the user
|
||||
* @param applicationName Name of the application
|
||||
* @returns True if the user has access, false otherwise
|
||||
*/
|
||||
checkUserHasApplicationAccess(userId: string, applicationName: string): Observable<boolean> {
|
||||
return this.getClientIdByApplicationName(applicationName).pipe(
|
||||
switchMap((clientId: string) => {
|
||||
return this.checkUserHasClientApp(userId, clientId);
|
||||
})
|
||||
switchMap((clientId: string) => this.checkUserHasClientApp(userId, clientId))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a user has any application role.
|
||||
*
|
||||
* @param userId ID of the target user
|
||||
* @param applicationName Name of the application
|
||||
* @param roleNames List of role names to check for
|
||||
@@ -202,14 +211,13 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
*/
|
||||
checkUserHasAnyApplicationRole(userId: string, applicationName: string, roleNames: string[]): Observable<boolean> {
|
||||
return this.getClientIdByApplicationName(applicationName).pipe(
|
||||
switchMap((clientId: string) => {
|
||||
return this.checkUserHasAnyClientAppRole(userId, clientId, roleNames);
|
||||
})
|
||||
switchMap((clientId: string) => this.checkUserHasAnyClientAppRole(userId, clientId, roleNames))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets details for all users.
|
||||
*
|
||||
* @returns Array of user info objects
|
||||
*/
|
||||
getUsers(): Observable<IdentityUserModel[]> {
|
||||
@@ -219,6 +227,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Gets a list of roles for a user.
|
||||
*
|
||||
* @param userId ID of the user
|
||||
* @returns Array of role info objects
|
||||
*/
|
||||
@@ -229,6 +238,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Gets an array of users (including the current user) who have any of the roles in the supplied list.
|
||||
*
|
||||
* @param roleNames List of role names to look for
|
||||
* @returns Array of user info objects
|
||||
*/
|
||||
@@ -250,6 +260,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Gets an array of users (not including the current user) who have any of the roles in the supplied list.
|
||||
*
|
||||
* @param roleNames List of role names to look for
|
||||
* @returns Array of user info objects
|
||||
*/
|
||||
@@ -275,9 +286,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
private async userHasAnyRole(userId: string, roleNames: string[]): Promise<boolean> {
|
||||
const userRoles = await this.getUserRoles(userId).toPromise();
|
||||
const hasAnyRole = roleNames.some((roleName) => {
|
||||
const filteredRoles = userRoles.filter((userRole) => {
|
||||
return userRole.name.toLocaleLowerCase() === roleName.toLocaleLowerCase();
|
||||
});
|
||||
const filteredRoles = userRoles.filter((userRole) => userRole.name.toLocaleLowerCase() === roleName.toLocaleLowerCase());
|
||||
|
||||
return filteredRoles.length > 0;
|
||||
});
|
||||
@@ -287,6 +296,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Checks if a user has one of the roles from a list.
|
||||
*
|
||||
* @param userId ID of the target user
|
||||
* @param roleNames Array of roles to check for
|
||||
* @returns True if the user has one of the roles, false otherwise
|
||||
@@ -309,6 +319,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Gets details for all users.
|
||||
*
|
||||
* @returns Array of user information objects.
|
||||
*/
|
||||
queryUsers(requestQuery: IdentityUserQueryCloudRequestModel): Observable<IdentityUserQueryResponse> {
|
||||
@@ -318,18 +329,16 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
return this.getTotalUsersCount().pipe(
|
||||
switchMap((totalCount) =>
|
||||
this.oAuth2Service.get<IdentityUserModel[]>({ url, queryParams }).pipe(
|
||||
map((response) => {
|
||||
return <IdentityUserQueryResponse> {
|
||||
entries: response,
|
||||
pagination: {
|
||||
skipCount: requestQuery.first,
|
||||
maxItems: requestQuery.max,
|
||||
count: totalCount,
|
||||
hasMoreItems: false,
|
||||
totalItems: totalCount
|
||||
}
|
||||
};
|
||||
})
|
||||
map((response) => ({
|
||||
entries: response,
|
||||
pagination: {
|
||||
skipCount: requestQuery.first,
|
||||
maxItems: requestQuery.max,
|
||||
count: totalCount,
|
||||
hasMoreItems: false,
|
||||
totalItems: totalCount
|
||||
}
|
||||
} as IdentityUserQueryResponse))
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -337,6 +346,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Gets users total count.
|
||||
*
|
||||
* @returns Number of users count.
|
||||
*/
|
||||
getTotalUsersCount(): Observable<number> {
|
||||
@@ -346,6 +356,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Creates new user.
|
||||
*
|
||||
* @param newUser Object containing the new user details.
|
||||
* @returns Empty response when the user created.
|
||||
*/
|
||||
@@ -358,6 +369,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Updates user details.
|
||||
*
|
||||
* @param userId Id of the user.
|
||||
* @param updatedUser Object containing the user details.
|
||||
* @returns Empty response when the user updated.
|
||||
@@ -371,6 +383,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Deletes User.
|
||||
*
|
||||
* @param userId Id of the user.
|
||||
* @returns Empty response when the user deleted.
|
||||
*/
|
||||
@@ -381,6 +394,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Changes user password.
|
||||
*
|
||||
* @param userId Id of the user.
|
||||
* @param credentials Details of user Credentials.
|
||||
* @returns Empty response when the password changed.
|
||||
@@ -394,6 +408,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Gets involved groups.
|
||||
*
|
||||
* @param userId Id of the user.
|
||||
* @returns Array of involved groups information objects.
|
||||
*/
|
||||
@@ -406,6 +421,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Joins group.
|
||||
*
|
||||
* @param joinGroupRequest Details of join group request (IdentityJoinGroupRequestModel).
|
||||
* @returns Empty response when the user joined the group.
|
||||
*/
|
||||
@@ -418,6 +434,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Leaves group.
|
||||
*
|
||||
* @param userId Id of the user.
|
||||
* @param groupId Id of the group.
|
||||
* @returns Empty response when the user left the group.
|
||||
@@ -429,6 +446,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Gets available roles
|
||||
*
|
||||
* @param userId Id of the user.
|
||||
* @returns Array of available roles information objects
|
||||
*/
|
||||
@@ -439,6 +457,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Gets assigned roles.
|
||||
*
|
||||
* @param userId Id of the user.
|
||||
* @returns Array of assigned roles information objects
|
||||
*/
|
||||
@@ -451,6 +470,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Gets effective roles.
|
||||
*
|
||||
* @param userId Id of the user.
|
||||
* @returns Array of composite roles information objects
|
||||
*/
|
||||
@@ -463,6 +483,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Assigns roles to the user.
|
||||
*
|
||||
* @param userId Id of the user.
|
||||
* @param roles Array of roles.
|
||||
* @returns Empty response when the role assigned.
|
||||
@@ -476,6 +497,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
|
||||
|
||||
/**
|
||||
* Removes assigned roles.
|
||||
*
|
||||
* @param userId Id of the user.
|
||||
* @param roles Array of roles.
|
||||
* @returns Empty response when the role removed.
|
||||
|
Reference in New Issue
Block a user