AuthService

Source: AuthService.ts:9

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


Constructor

new AuthService(): AuthService

Instance Methods

saveLoginToken(token: string)

Parameters

  • token (string) — The authentication token to store

login(username: string, password: string): Boolean

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

Parameters

  • username (string) — The username of the user
  • password (string) — The password of the user

Returns

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

ssoLogin(ssoToken: string): Boolean

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

Parameters

  • ssoToken (string) — The SSO token received from the SSO provider

Returns

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

requestSSO(email: string): unknown

Request an SSO login link for the given email address.

Parameters

  • email (string) — The email address to request the SSO link for

Returns

  • unknown — Returns the response data from the server

register( username: string, password: string, email: string, ): Boolean

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

Parameters

  • username (string) — The username of the user
  • password (string) — The password of the user
  • email (string) — The email address of the user

Returns

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

logout(): void

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

Returns

  • void

changePassword(password: string): unknown

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

Parameters

  • password (string) — The new password to set for the user

Returns

  • unknown — Returns the response data from the server

updateUserInfo(username: string, email: string): unknown

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

Parameters

  • username (string) — The new username to set for the user
  • email (string) — The new email address to set for the user

Returns

  • unknown — Returns the response data from the server

updateProfilePicture(profilePicture: File): Promise.<unknown>

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

Parameters

  • profilePicture (File) — The new profile picture file to upload

Returns

  • Promise.<unknown> — Returns the response data from the server

deleteAccount(): Promise.<unknown>

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

Returns

  • Promise.<unknown> — Returns the response data from the server

getAuthToken(): string

Get the authentication token from local storage

Returns

  • string

removeToken(): void

Remove the authentication token from local storage

Returns

  • void

getUserInfo(): Promise.<User>

Get the user information of the currently logged-in user

Returns

  • Promise.<User> — Returns the user information from the server

getProfileImage( userId: string, extension: string, ): Promise.<string>

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

Parameters

  • userId (string) — The ID of the user whose profile image is requested
  • extension (string) — The file extension of the profile image (e.g., 'jpg', 'png')

Returns

  • Promise.<string> — Returns a promise that resolves to the profile image blob

deleteProfilePicture(): Promise.<unknown>

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

Returns

  • Promise.<unknown> — Returns the response data from the server

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

Returns

  • Promise.<unknown> — Returns the response data from the server