Account

Struct Account 

Source
pub struct Account { /* private fields */ }

Implementations§

Source§

impl Account

Source

pub fn new(client: &Client) -> Self

Source

pub fn get(&self) -> Result<User, AppwriteException>

Get currently logged in user data as JSON object.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn update_name(&self, name: &str) -> Result<User, AppwriteException>

Update currently logged in user account name.

Source

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.

Source

pub fn get_prefs(&self) -> Result<Preferences, AppwriteException>

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

Source

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.

Source

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.

Source

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.

Source

pub fn get_sessions(&self) -> Result<SessionList, AppwriteException>

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

Source

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.

Source

pub fn delete_sessions(&self) -> Result<Value, AppwriteException>

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

Source

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.

Source

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.

Source

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.

Source

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..

Source

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.

Source

pub fn update_session( &self, session_id: &str, ) -> Result<Session, AppwriteException>

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Account

Source§

fn clone(&self) -> Account

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,