pub struct Account { /* private fields */ }Implementations§
Source§impl Account
impl Account
pub fn new(client: &Client) -> Self
Sourcepub fn get(&self) -> Result<User, AppwriteException>
pub fn get(&self) -> Result<User, AppwriteException>
Get currently logged in user data as JSON object.
Sourcepub fn create(
&self,
user_id: &str,
email: &str,
password: &str,
name: Option<&str>,
) -> Result<User, AppwriteException>
pub fn create( &self, user_id: &str, email: &str, password: &str, name: Option<&str>, ) -> Result<User, AppwriteException>
Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the /account/verfication route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new account session.
Sourcepub fn delete(&self) -> Result<Value, AppwriteException>
pub fn delete(&self) -> Result<Value, AppwriteException>
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.
Sourcepub fn update_email(
&self,
email: &str,
password: &str,
) -> Result<User, AppwriteException>
pub fn update_email( &self, email: &str, password: &str, ) -> Result<User, AppwriteException>
Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. 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.
Sourcepub fn create_jwt(&self) -> Result<Jwt, AppwriteException>
pub fn create_jwt(&self) -> Result<Jwt, AppwriteException>
Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame.
Sourcepub fn get_logs(
&self,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<LogList, AppwriteException>
pub fn get_logs( &self, limit: Option<i64>, offset: Option<i64>, ) -> Result<LogList, AppwriteException>
Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.
Sourcepub fn update_name(&self, name: &str) -> Result<User, AppwriteException>
pub fn update_name(&self, name: &str) -> Result<User, AppwriteException>
Update currently logged in user account name.
Sourcepub fn update_password(
&self,
password: &str,
old_password: Option<&str>,
) -> Result<User, AppwriteException>
pub fn update_password( &self, password: &str, old_password: Option<&str>, ) -> Result<User, AppwriteException>
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.
Sourcepub fn get_prefs(&self) -> Result<Preferences, AppwriteException>
pub fn get_prefs(&self) -> Result<Preferences, AppwriteException>
Get currently logged in user preferences as a key-value object.
Sourcepub fn update_prefs(
&self,
prefs: Option<HashMap<String, ParamType>>,
) -> Result<User, AppwriteException>
pub fn update_prefs( &self, prefs: Option<HashMap<String, ParamType>>, ) -> Result<User, AppwriteException>
Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded.
Sourcepub fn create_recovery(
&self,
email: &str,
url: &str,
) -> Result<Token, AppwriteException>
pub fn create_recovery( &self, email: &str, url: &str, ) -> Result<Token, AppwriteException>
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.
Sourcepub fn update_recovery(
&self,
user_id: &str,
secret: &str,
password: &str,
password_again: &str,
) -> Result<Token, AppwriteException>
pub fn update_recovery( &self, user_id: &str, secret: &str, password: &str, password_again: &str, ) -> Result<Token, AppwriteException>
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.
Sourcepub fn get_sessions(&self) -> Result<SessionList, AppwriteException>
pub fn get_sessions(&self) -> Result<SessionList, AppwriteException>
Get currently logged in user list of active sessions across different devices.
Sourcepub fn create_session(
&self,
email: &str,
password: &str,
) -> Result<Session, AppwriteException>
pub fn create_session( &self, email: &str, password: &str, ) -> Result<Session, AppwriteException>
Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.
Sourcepub fn delete_sessions(&self) -> Result<Value, AppwriteException>
pub fn delete_sessions(&self) -> Result<Value, AppwriteException>
Delete all sessions from the user account and remove any sessions cookies from the end client.
Sourcepub fn create_anonymous_session(&self) -> Result<Session, AppwriteException>
pub fn create_anonymous_session(&self) -> Result<Session, AppwriteException>
Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its email and password or create an OAuth2 session.
Sourcepub fn create_magic_url_session(
&self,
user_id: &str,
email: &str,
url: Option<&str>,
) -> Result<Token, AppwriteException>
pub fn create_magic_url_session( &self, user_id: &str, email: &str, url: Option<&str>, ) -> Result<Token, AppwriteException>
Sends the user an email with a secret key for creating a session. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the PUT /account/sessions/magic-url endpoint to complete the login process. The link sent to the user’s email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.
Sourcepub fn update_magic_url_session(
&self,
user_id: &str,
secret: &str,
) -> Result<Session, AppwriteException>
pub fn update_magic_url_session( &self, user_id: &str, secret: &str, ) -> Result<Session, AppwriteException>
Use this endpoint to complete creating the session with the Magic URL. 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/sessions/magic-url 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.
Sourcepub fn create_o_auth2_session(
&self,
provider: &str,
success: Option<&str>,
failure: Option<&str>,
scopes: Option<&[&str]>,
) -> Result<Value, AppwriteException>
pub fn create_o_auth2_session( &self, provider: &str, success: Option<&str>, failure: Option<&str>, scopes: Option<&[&str]>, ) -> Result<Value, AppwriteException>
Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL’s back to your app when login is completed.
If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user..
Sourcepub fn get_session(
&self,
session_id: &str,
) -> Result<Session, AppwriteException>
pub fn get_session( &self, session_id: &str, ) -> Result<Session, AppwriteException>
Use this endpoint to get a logged in user’s session using a Session ID. Inputting ‘current’ will return the current session being used.
pub fn update_session( &self, session_id: &str, ) -> Result<Session, AppwriteException>
Sourcepub fn delete_session(
&self,
session_id: &str,
) -> Result<Value, AppwriteException>
pub fn delete_session( &self, session_id: &str, ) -> Result<Value, AppwriteException>
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 Session ID argument, only the unique session ID provided is deleted.
Sourcepub fn create_verification(&self, url: &str) -> Result<Token, AppwriteException>
pub fn create_verification(&self, url: &str) -> Result<Token, AppwriteException>
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.
Sourcepub fn update_verification(
&self,
user_id: &str,
secret: &str,
) -> Result<Token, AppwriteException>
pub fn update_verification( &self, user_id: &str, secret: &str, ) -> Result<Token, AppwriteException>
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.