pub struct Auth { /* private fields */ }
Expand description
Authentication client for handling user sessions and JWT tokens
Implementations§
Source§impl Auth
impl Auth
Sourcepub fn new(
config: Arc<SupabaseConfig>,
http_client: Arc<HttpClient>,
) -> Result<Self>
pub fn new( config: Arc<SupabaseConfig>, http_client: Arc<HttpClient>, ) -> Result<Self>
Create a new Auth instance
Sourcepub async fn sign_up_with_email_and_password(
&self,
email: &str,
password: &str,
) -> Result<AuthResponse>
pub async fn sign_up_with_email_and_password( &self, email: &str, password: &str, ) -> Result<AuthResponse>
Sign up a new user with email and password
Sourcepub async fn sign_up_with_email_password_and_data(
&self,
email: &str,
password: &str,
data: Option<Value>,
redirect_to: Option<String>,
) -> Result<AuthResponse>
pub async fn sign_up_with_email_password_and_data( &self, email: &str, password: &str, data: Option<Value>, redirect_to: Option<String>, ) -> Result<AuthResponse>
Sign up a new user with email, password, and optional metadata
Sourcepub async fn sign_in_with_email_and_password(
&self,
email: &str,
password: &str,
) -> Result<AuthResponse>
pub async fn sign_in_with_email_and_password( &self, email: &str, password: &str, ) -> Result<AuthResponse>
Sign in with email and password
Sourcepub async fn reset_password_for_email(&self, email: &str) -> Result<()>
pub async fn reset_password_for_email(&self, email: &str) -> Result<()>
Reset password via email
Sourcepub async fn reset_password_for_email_with_redirect(
&self,
email: &str,
redirect_to: Option<String>,
) -> Result<()>
pub async fn reset_password_for_email_with_redirect( &self, email: &str, redirect_to: Option<String>, ) -> Result<()>
Reset password via email with optional redirect URL
Sourcepub async fn update_user(
&self,
email: Option<String>,
password: Option<String>,
data: Option<Value>,
) -> Result<AuthResponse>
pub async fn update_user( &self, email: Option<String>, password: Option<String>, data: Option<Value>, ) -> Result<AuthResponse>
Update the current user’s information
Sourcepub async fn refresh_session(&self) -> Result<AuthResponse>
pub async fn refresh_session(&self) -> Result<AuthResponse>
Refresh the current session token
Sourcepub async fn current_user(&self) -> Result<Option<User>>
pub async fn current_user(&self) -> Result<Option<User>>
Get the current user information
Sourcepub fn get_session(&self) -> Result<Session>
pub fn get_session(&self) -> Result<Session>
Get the current session
Sourcepub async fn set_session(&self, session: Session) -> Result<()>
pub async fn set_session(&self, session: Session) -> Result<()>
Set a new session
Sourcepub async fn set_session_token(&self, token: &str) -> Result<()>
pub async fn set_session_token(&self, token: &str) -> Result<()>
Set session from JWT token
Sourcepub async fn clear_session(&self) -> Result<()>
pub async fn clear_session(&self) -> Result<()>
Clear the current session
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Check if the user is authenticated
Sourcepub fn needs_refresh(&self) -> bool
pub fn needs_refresh(&self) -> bool
Check if the current token needs refresh
Sourcepub async fn auto_refresh(&self) -> Result<()>
pub async fn auto_refresh(&self) -> Result<()>
Auto-refresh token if needed
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Auth
impl !RefUnwindSafe for Auth
impl Send for Auth
impl Sync for Auth
impl Unpin for Auth
impl !UnwindSafe for Auth
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more