AuthService

new AuthService()

Service for handling user authentication, including login, registration, and profile management.

Methods

changePassword(password) → {unknown}

Make a request to change the password of the currently logged-in user

Parameters:
NameTypeDescription
passwordstring

The new password to set for the user

Returns:

Returns the response data from the server

Type: 
unknown

deleteAccount() → {Promise.<unknown>}

Make a request to delete the currently logged-in user account

Returns:

Returns the response data from the server

Type: 
Promise.<unknown>

deleteProfilePicture() → {Promise.<unknown>}

Make a request to delete the profile picture of the currently logged-in user

Returns:

Returns the response data from the server

Type: 
Promise.<unknown>

getAuthToken() → {string}

Get the authentication token from local storage

Returns:
Type: 
string

getProfileImage(userId, extension) → {Promise.<string>}

Get the profile image of a user by user ID and image extension

Parameters:
NameTypeDescription
userIdstring

The ID of the user whose profile image is requested

extensionstring

The file extension of the profile image (e.g., 'jpg', 'png')

Returns:

Returns a promise that resolves to the profile image blob

Type: 
Promise.<string>

getUserInfo() → {Promise.<object>}

Get the user information of the currently logged-in user

Returns:

Returns the user information from the server

Type: 
Promise.<object>

(async) login(username, password) → {Boolean}

Make a login request with username and password and store the authentication token

Parameters:
NameTypeDescription
usernamestring

The username of the user

passwordstring

The password of the user

Returns:

Returns true if the login was successful, otherwise throws an error

Type: 
Boolean

(async) logout() → {void}

Remove the authentication token and redirect to the login page if the current route is private

Returns:
Type: 
void

(async) register(username, password, email) → {Boolean}

Make a registration request with username, password, and email and store the authentication token

Parameters:
NameTypeDescription
usernamestring

The username of the user

passwordstring

The password of the user

emailstring

The email address of the user

Returns:

Returns true if the registration was successful, otherwise throws an error

Type: 
Boolean

removeToken() → {void}

Remove the authentication token from local storage

Returns:
Type: 
void

(async) requestSSO(email) → {unknown}

Request an SSO login link for the given email address.

Parameters:
NameTypeDescription
emailstring

The email address to request the SSO link for

Returns:

Returns the response data from the server

Type: 
unknown

Make a request to resend the email confirmation link for the currently logged-in user

Returns:

Returns the response data from the server

Type: 
Promise.<unknown>

(async) ssoLogin(ssoToken) → {Boolean}

Make a login request with an SSO token and store the authentication token

Parameters:
NameTypeDescription
ssoTokenstring

The SSO token received from the SSO provider

Returns:

Returns true if the login was successful, otherwise throws an error

Type: 
Boolean

updateProfilePicture(profilePicture) → {Promise.<unknown>}

Make a request to update the profile picture of the currently logged-in user

Parameters:
NameTypeDescription
profilePictureFile

The new profile picture file to upload

Returns:

Returns the response data from the server

Type: 
Promise.<unknown>

updateUserInfo(username, email) → {unknown}

Make a request to update the user information of the currently logged-in user

Parameters:
NameTypeDescription
usernamestring

The new username to set for the user

emailstring

The new email address to set for the user

Returns:

Returns the response data from the server

Type: 
unknown