Interface IUserService
- Namespace
- adas_core.Authentication.Interfaces
- Assembly
- adas-core.Authentication.dll
public interface IUserService
- Extension Methods
Fields
TokenTypeRefresh
public static readonly string TokenTypeRefresh
Field Value
TokenTypeUser
public static readonly string TokenTypeUser
Field Value
Methods
CreateNewAuthority(Authorization)
Asynchronously creates a new authority based on the provided authorization data.
Task<Authorization> CreateNewAuthority(Authorization auth)
Parameters
authAuthorizationThe authorization information used to create the new authority.
Returns
- Task<Authorization>
A task that represents the asynchronous operation. The task result contains the created Authorization.
CreateNewUserByRequest(User)
Creates a new user based on the provided user data, typically originating from an incoming request. Returns the newly created user, or null if the user could not be created.
Task<User?> CreateNewUserByRequest(User user)
Parameters
userUserThe user data to use for creating the new user.
Returns
- Task<User>
A task that represents the asynchronous operation. The result is the created User, or null if creation failed.
CreateNewUserWithAuthorities(CreateUserWithAuthDto)
Creates a new user together with the associated authorities based on the supplied data transfer object.
Task<User?> CreateNewUserWithAuthorities(CreateUserWithAuthDto createUserWithAuthDto)
Parameters
createUserWithAuthDtoCreateUserWithAuthDtoThe data transfer object containing the information required to create the user and its authorities.
Returns
- Task<User>
A task that represents the asynchronous operation. The task result contains the created User instance, or
nullif no user was created.
CreateUser(User)
Creates a user from the provided LDAP user entry.
Task<User?> CreateUser(User userEntryLdap)
Parameters
userEntryLdapUserThe LDAP user entry used to create the user.
Returns
- Task<User>
A task that represents the asynchronous create operation, containing the created User or
null.
DeleteAuthority(string)
Asynchronously deletes an authority identified by the specified identifier.
Task<bool> DeleteAuthority(string id)
Parameters
idstringThe unique identifier of the authority to delete.
Returns
- Task<bool>
A task that represents the asynchronous delete operation. The task result contains a boolean indicating whether the authority was successfully deleted.
DeleteUser(ObjectId)
Asynchronously deletes a user identified by the specified identifier.
Task<bool> DeleteUser(ObjectId id)
Parameters
idObjectIdThe unique identifier of the user to delete.
Returns
- Task<bool>
A task that represents the asynchronous operation, containing a value indicating whether the user was successfully deleted.
GenerateJwt(User)
Asynchronously generates a JSON Web Token (JWT) for the specified user and returns the token result.
Task<TokenResult> GenerateJwt(User user)
Parameters
userUserThe user for whom the JWT is being generated.
Returns
- Task<TokenResult>
A task that represents the asynchronous operation, containing the TokenResult with the generated token details.
GetAll()
Asynchronously retrieves all users from the data store.
Task<List<User>> GetAll()
Returns
- Task<List<User>>
A task that represents the asynchronous operation. The task result contains a list of all User entities.
GetPaginatedUsers(PaginationFilter)
Retrieves a paginated list of users based on the provided pagination filter configuration.
Task<PaginationResponse<User>> GetPaginatedUsers(PaginationFilter config)
Parameters
configPaginationFilterThe pagination filter that defines paging parameters such as page number and page size.
Returns
- Task<PaginationResponse<User>>
A task that represents the asynchronous operation, containing the paginated response of User entries.
GetUser(string, string)
Authenticates a user based on the provided username and password and returns the corresponding user.
Task<User> GetUser(string username, string password)
Parameters
usernamestringThe username of the user to authenticate.
passwordstringThe password of the user to authenticate.
Returns
- Task<User>
A task that represents the asynchronous operation. The task result contains the authenticated User.
GetUserByCasTicket(string, string)
Asynchronously retrieves a user by validating a CAS (Central Authentication Service) ticket against the specified service.
Task<User?> GetUserByCasTicket(string service, string ticket)
Parameters
servicestringThe service URL or identifier that the ticket was issued for and must be validated against.
ticketstringThe CAS ticket string used to authenticate and identify the user.
Returns
- Task<User>
A task that represents the asynchronous operation. The task result contains the associated User if the ticket is valid, or
nullif the user cannot be found.
GetUserById(ObjectId)
Asynchronously retrieves a user by their unique identifier, returning null when no user matches the provided id.
Task<User?> GetUserById(ObjectId id)
Parameters
idObjectIdThe unique MongoDB.Bson.ObjectId identifier of the user to look up.
Returns
GetUserByName(string)
Asynchronously retrieves a user matching the specified name, returning null when no matching user is found.
Task<User?> GetUserByName(string name)
Parameters
namestringThe name used to look up the user.
Returns
- Task<User>
A task that resolves to the matching User, or
nullif no user with the given name exists.
GetUserByToken(JwtSecurityToken?)
Retrieves the user associated with the provided JWT security token.
Returns null if the token is null or if no matching user is found.
Task<User?> GetUserByToken(JwtSecurityToken? jwtToken)
Parameters
jwtTokenJwtSecurityTokenThe JWT security token used to identify the user. May be
null.
Returns
- Task<User>
A task that resolves to the User associated with the token, or
nullif the token is invalid or no user matches.
GetUserByUserName(string)
Asynchronously retrieves a user by their unique username, returning null when no matching user is found.
Task<User?> GetUserByUserName(string name)
Parameters
namestringThe username used to look up the user.
Returns
- Task<User>
A task that represents the asynchronous operation, containing the matching user if found; otherwise, null.
Login(string, string)
Authenticates a user with the provided credentials and returns a token result upon successful login.
Task<TokenResult> Login(string username, string password)
Parameters
usernamestringThe username of the user attempting to log in.
passwordstringThe password associated with the specified username.
Returns
- Task<TokenResult>
A task that represents the asynchronous login operation, containing the TokenResult with the authentication token information.
LoginWithAccessToken(string)
Authenticates a user by exchanging a provided access token for a login result.
Task<TokenResult> LoginWithAccessToken(string token)
Parameters
tokenstringThe access token used to authenticate the user.
Returns
- Task<TokenResult>
A task that represents the asynchronous login operation, containing the TokenResult with the outcome of the authentication.
LoginWithGivenAccessToken(string)
Authenticates the user using the provided access token and returns the resulting token information.
Task<TokenResult> LoginWithGivenAccessToken(string token)
Parameters
tokenstringThe access token used to perform the login.
Returns
- Task<TokenResult>
A task that represents the asynchronous login operation, containing the token result.
RefreshToken(string)
Refreshes an authentication token using the provided refresh token and returns the resulting token information.
Task<TokenResult> RefreshToken(string refreshToken)
Parameters
refreshTokenstringThe refresh token used to obtain a new access token.
Returns
- Task<TokenResult>
A Task<TResult> that represents the asynchronous operation, containing the TokenResult with the refreshed token details.
UpdateAuthority(Authorization)
Updates the authority information based on the provided authorization data.
Task<bool> UpdateAuthority(Authorization authorization)
Parameters
authorizationAuthorizationThe authorization entity containing the authority details to be updated.
Returns
- Task<bool>
A task that represents the asynchronous operation. The task result is
trueif the update was successful; otherwise,false.
UpdateUserPassword(ObjectId, string, string)
Updates the password for the user identified by the specified identifier, verifying the old password before applying the new one.
Task<bool> UpdateUserPassword(ObjectId id, string oldPassword, string newPassword)
Parameters
idObjectIdThe unique identifier of the user whose password will be updated.
oldPasswordstringThe user's current password, used to verify the request.
newPasswordstringThe new password to set for the user.
Returns
- Task<bool>
A task that represents the asynchronous operation. The task result is
trueif the password was updated successfully; otherwise,false.
UpdateUserWithAuthorities(UpdateUserWithAuthDto, bool)
Updates an existing user along with the associated authorities, optionally updating the password.
Task<User?> UpdateUserWithAuthorities(UpdateUserWithAuthDto createUserWithAuthDto, bool updatePass)
Parameters
createUserWithAuthDtoUpdateUserWithAuthDtoThe data transfer object containing the user information and authorities to update.
updatePassboolA flag indicating whether the user's password should be updated as part of the operation.
Returns
- Task<User>
A task that represents the asynchronous operation, containing the updated User or
nullif the user was not found.
UpdateUsersByRequest(User, bool)
Updates a user's information based on the provided user data, with an option to include password updates.
Task<User?> UpdateUsersByRequest(User user, bool updatePass)
Parameters
userUserThe user entity containing the updated information to be persisted.
updatePassboolA flag indicating whether the user's password should be updated during this operation.
Returns
ValidateToken(string, string, out SecurityToken)
Validates the specified token according to its type and outputs the corresponding SecurityToken.
void ValidateToken(string token, string tokenType, out SecurityToken securityToken)
Parameters
tokenstringThe token string to be validated.
tokenTypestringThe type of the token, used to determine the appropriate validation strategy.
securityTokenSecurityTokenWhen the method returns, contains the validated SecurityToken if validation succeeds.