Skip to content

IAuthenticationService

Namespace: Rest_API.Services.Auth

Service interface for handling user authentication, registration, and user management operations.

public interface IAuthenticationService

Methods

ChangePassword(ApiUser, String, String)

Changes a user's password after validating the current password.

Task ChangePassword(ApiUser user, string currentPassword, string newPassword)

Parameters

user ApiUser

The user whose password will be changed.

currentPassword String

The user's current password for validation.

newPassword String

The new password to set.

Returns

A task representing the asynchronous password change operation.

Exceptions

ArgumentException

Thrown when parameters are null or invalid.

UnauthorizedAccessException

Thrown when current password is incorrect.

ChangeUser(ApiUser)

Updates user information in the system.

Task ChangeUser(ApiUser user)

Parameters

user ApiUser

The user object with updated information.

Returns

A task representing the asynchronous user update operation.

Exceptions

ArgumentException

Thrown when user is null or contains invalid data.

InvalidOperationException

Thrown when user update fails.

DeleteUser(ApiUser)

Deletes a user from the system.

Task<Boolean> DeleteUser(ApiUser user)

Parameters

user ApiUser

The user to delete from the system.

Returns

A task containing true if deletion was successful, false otherwise.

Exceptions

ArgumentException

Thrown when user is null.

InvalidOperationException

Thrown when user deletion fails.

GetUserById(String)

Retrieves a specific user by their unique identifier.

Task<ApiUser> GetUserById(string userId)

Parameters

userId String

The unique identifier of the user to retrieve.

Returns

A task containing the user if found, or null if not found.

Exceptions

ArgumentException

Thrown when userId is null or empty.

GetUserInformations()

Retrieves a list of all users in the system.

Task<List<ApiUser>> GetUserInformations()

Returns

A task containing a list of all API users.

Exceptions

UnauthorizedAccessException

Thrown when user lacks sufficient permissions.

Login(Login)

Authenticates a user and returns JWT tokens for session management.

Task<JwtToken> Login(Login input)

Parameters

input Login

Login credentials containing username and password.

Returns

A task containing JWT access and refresh tokens.

Exceptions

UnauthorizedAccessException

Thrown when credentials are invalid.

ArgumentException

Thrown when login data is invalid.

RefreshToken(JwtToken)

Refreshes an expired access token using a valid refresh token.

Task<JwtToken> RefreshToken(JwtToken tokenModel)

Parameters

tokenModel JwtToken

JWT token model containing the refresh token.

Returns

A task containing new JWT access and refresh tokens.

Exceptions

UnauthorizedAccessException

Thrown when refresh token is invalid or expired.

ArgumentException

Thrown when token model is null or invalid.

Register(Register)

Registers a new user in the system.

Task Register(Register input)

Parameters

input Register

Registration data containing user credentials and information.

Returns

A task representing the asynchronous registration operation.

Exceptions

ArgumentException

Thrown when registration data is invalid.

InvalidOperationException

Thrown when user already exists or registration fails.