new AuthService()
Service for handling user authentication, including login, registration, and profile management.
- Source
Methods
changePassword(password) → {unknown}
Make a request to change the password of the currently logged-in user
| Name | Type | Description |
|---|---|---|
password | string | The new password to set for the user |
- Source
Returns the response data from the server
- Type:
- unknown
deleteAccount() → {Promise.<unknown>}
Make a request to delete the currently logged-in user account
- Source
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
- Source
Returns the response data from the server
- Type:
- Promise.<unknown>
getAuthToken() → {string}
Get the authentication token from local storage
- Source
- Type:
- string
getProfileImage(userId, extension) → {Promise.<string>}
Get the profile image of a user by user ID and image extension
| Name | Type | Description |
|---|---|---|
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') |
- Source
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
- Source
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
| Name | Type | Description |
|---|---|---|
username | string | The username of the user |
password | string | The password of the user |
- Source
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
- Source
- Type:
- void
(async) register(username, password, email) → {Boolean}
Make a registration request with username, password, and email and store the authentication token
| Name | Type | Description |
|---|---|---|
username | string | The username of the user |
password | string | The password of the user |
email | string | The email address of the user |
- Source
Returns true if the registration was successful, otherwise throws an error
- Type:
- Boolean
removeToken() → {void}
Remove the authentication token from local storage
- Source
- Type:
- void
(async) requestSSO(email) → {unknown}
Request an SSO login link for the given email address.
| Name | Type | Description |
|---|---|---|
email | string | The email address to request the SSO link for |
- Source
Returns the response data from the server
- Type:
- unknown
resendEmailConfirmationLink() → {Promise.<unknown>}
Make a request to resend the email confirmation link for the currently logged-in user
- Source
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
| Name | Type | Description |
|---|---|---|
ssoToken | string | The SSO token received from the SSO provider |
- Source
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
| Name | Type | Description |
|---|---|---|
profilePicture | File | The new profile picture file to upload |
- Source
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
| Name | Type | Description |
|---|---|---|
username | string | The new username to set for the user |
email | string | The new email address to set for the user |
- Source
Returns the response data from the server
- Type:
- unknown