TypeScript UserService Documentation
Methods
- createUser
- deleteUserByEmail
- deleteUserById
- getAuthIdById
- getUserByEmail
- getUserById
- getUserIdByAuthId
- getUserRoleByAuthId
- getUsers
- updateUserById
createUser
▸ createUser(user
: CreateUserDTO, authId?
: string | null, signUpMethod?
: SignUpMethod): Promise<UserDTO>
Create a user
throws
Error if user creation fails
Parameters
Name | Type | Description |
---|---|---|
user | CreateUserDTO | the user to be created |
authId? | string | the user’s firebase auth id, optional |
signUpMethod? | SignUpMethod | the method user used to signup |
Returns: Promise<UserDTO>
a UserDTO with the created user’s information
deleteUserByEmail
▸ deleteUserByEmail(email
: string): Promise<void>
Delete a user by email
throws
Error if user deletion fails
Parameters
Name | Type | Description |
---|---|---|
email | string | user’s email |
Returns: Promise<void>
deleteUserById
▸ deleteUserById(userId
: string): Promise<void>
Delete a user by id
throws
Error if user deletion fails
Parameters
Name | Type | Description |
---|---|---|
userId | string | user’s userId |
Returns: Promise<void>
getAuthIdById
▸ getAuthIdById(userId
: string): Promise<string>
Get authId of user associated with id
throws
Error if user authId retrieval fails
Parameters
Name | Type | Description |
---|---|---|
userId | string | user’s id |
Returns: Promise<string>
user’s authId
getUserByEmail
▸ getUserByEmail(email
: string): Promise<UserDTO>
Get user associated with email
throws
Error if user retrieval fails
Parameters
Name | Type | Description |
---|---|---|
email | string | user’s email |
Returns: Promise<UserDTO>
a UserDTO with user’s information
getUserById
▸ getUserById(userId
: string): Promise<UserDTO>
Get user associated with id
throws
Error if user retrieval fails
Parameters
Name | Type |
---|---|
userId | string |
Returns: Promise<UserDTO>
a UserDTO with user’s information
getUserIdByAuthId
▸ getUserIdByAuthId(authId
: string): Promise<string>
Get id of user associated with authId
throws
Error if user id retrieval fails
Parameters
Name | Type | Description |
---|---|---|
authId | string | user’s authId |
Returns: Promise<string>
id of the user
getUserRoleByAuthId
▸ getUserRoleByAuthId(authId
: string): Promise<Role>
Get role of user associated with authId
throws
Error if user role retrieval fails
Parameters
Name | Type | Description |
---|---|---|
authId | string | user’s authId |
Returns: Promise<Role>
role of the user
getUsers
▸ getUsers(): Promise<UserDTO[]>
Get all user information (possibly paginated in the future)
throws
Error if user retrieval fails
Returns: Promise<UserDTO[]>
array of UserDTOs
updateUserById
▸ updateUserById(userId
: string, user
: UpdateUserDTO): Promise<UserDTO>
Update a user. Note: the password cannot be updated using this method, use IAuthService.resetPassword instead
throws
Error if user update fails
Parameters
Name | Type | Description |
---|---|---|
userId | string | user’s id |
user | UpdateUserDTO | the user to be updated |
Returns: Promise<UserDTO>
a UserDTO with the updated user’s information