Skip to main content
Module

x/appwrite/mod.ts>Account

[READ-ONLY] Official Appwrite Deno SDK 🦕
Go to Latest
class Account
extends Service
Re-export
import { Account } from "https://deno.land/x/appwrite@0.3.0/mod.ts";

Methods

createRecovery<T extends unknown>(email: string, url: string): Promise<T>

Create Password Recovery

Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the PUT /account/recovery endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour.

createVerification<T extends unknown>(url: string): Promise<T>

Create Email Verification

Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the userId and secret arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the userId and secret parameters. Learn more about how to complete the verification process. The verification link sent to the user's email address is valid for 7 days.

Please note that in order to avoid a Redirect Attack, the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.

delete<T extends unknown>(): Promise<T>

Delete Account

Delete a currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. This is done to avoid deleted accounts being overtaken by new users with the same email address. Any user-related resources like documents or storage files should be deleted separately.

deleteSession<T extends unknown>(sessionId: string): Promise<T>

Delete Account Session

Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the option id argument, only the session unique ID provider will be deleted.

deleteSessions<T extends unknown>(): Promise<T>

Delete All Account Sessions

Delete all sessions from the user account and remove any sessions cookies from the end client.

get<T extends unknown>(): Promise<T>

Get Account

Get currently logged in user data as JSON object.

getLogs<T extends unknown>(): Promise<T>

Get Account Logs

Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.

getPrefs<T extends unknown>(): Promise<T>

Get Account Preferences

Get currently logged in user preferences as a key-value object.

getSession<T extends unknown>(sessionId: string): Promise<T>

Get Session By ID

Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used.

getSessions<T extends unknown>(): Promise<T>

Get Account Sessions

Get currently logged in user list of active sessions across different devices.

updateEmail<T extends unknown>(email: string, password: string): Promise<T>

Update Account Email

Update currently logged in user account email address. After changing user address, user confirmation status is being reset and a new confirmation mail is sent. For security measures, user password is required to complete this request. This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password.

updateName<T extends unknown>(name: string): Promise<T>

Update Account Name

Update currently logged in user account name.

updatePassword<T extends unknown>(password: string, oldPassword?: string): Promise<T>

Update Account Password

Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth and Team Invites, oldPassword is optional.

updatePrefs<T extends unknown>(prefs: object): Promise<T>

Update Account Preferences

Update currently logged in user account preferences. You can pass only the specific settings you wish to update.

updateRecovery<T extends unknown>(
userId: string,
secret: string,
password: string,
passwordAgain: string,
): Promise<T>

Complete Password Recovery

Use this endpoint to complete the user account password reset. Both the userId and secret arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the POST /account/recovery endpoint.

Please note that in order to avoid a Redirect Attack the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.

updateVerification<T extends unknown>(userId: string, secret: string): Promise<T>

Complete Email Verification

Use this endpoint to complete the user email verification process. Use both the userId and secret parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.