@realm/react
Version:
React specific hooks and implementation helpers for Realm
94 lines • 3.96 kB
TypeScript
import { AuthResult } from "./types";
interface UseEmailPasswordAuth {
/**
* Convenience function to log in a user with an email and password - users
* could also call `logIn(Realm.Credentials.emailPassword(email, password))`.
* @see https://www.mongodb.com/docs/realm/sdk/react-native/manage-users/manage-email-password-users/#add-appprovider-to-work-with-email-password-users
*/
logIn(credentials: {
email: string;
password: string;
}): void;
/**
* Register a new user.
* @see https://www.mongodb.com/docs/realm/sdk/react-native/manage-users/manage-email-password-users/#register-a-new-user-account
*/
register(args: {
email: string;
password: string;
}): void;
/**
* Confirm a user's account by providing the `token` and `tokenId` received.
* @see https://www.mongodb.com/docs/realm/sdk/react-native/manage-users/manage-email-password-users/#confirm-a-new-user-s-email-address
*/
confirm(args: {
token: string;
tokenId: string;
}): void;
/**
* Resend a user's confirmation email.
* @see https://www.mongodb.com/docs/realm/sdk/react-native/manage-users/manage-email-password-users/#resend-a-confirmation-email
*/
resendConfirmationEmail(args: {
email: string;
}): void;
/**
* Retry the custom confirmation function for a given user.
* @see https://www.mongodb.com/docs/realm/sdk/react-native/manage-users/manage-email-password-users/#retry-a-user-confirmation-function
*/
retryCustomConfirmation(args: {
email: string;
}): void;
/**
* Send a password reset email for a given user.
* @see https://www.mongodb.com/docs/realm/sdk/react-native/manage-users/manage-email-password-users/#send-a-password-reset-email
*/
sendResetPasswordEmail(args: {
email: string;
}): void;
/**
* Complete resetting a user's password.
* @see https://www.mongodb.com/docs/realm/sdk/react-native/manage-users/manage-email-password-users/#send-a-password-reset-email
*/
resetPassword(args: {
token: string;
tokenId: string;
password: string;
}): void;
/**
* Call the configured password reset function, passing in any additional
* arguments to the function.
* @see https://www.mongodb.com/docs/realm/sdk/react-native/manage-users/manage-email-password-users/#call-a-password-reset-function
*/
callResetPasswordFunction<Args extends unknown[] = []>(args: {
email: string;
password: string;
}, ...restArgs: Args): void;
/**
* Log out the current user.
* @see https://www.mongodb.com/docs/realm/sdk/react-native/manage-users/authenticate-users/#log-a-user-out
*/
logOut(): void;
/**
* The {@link AuthResult} of the current (or last) operation performed for
* this hook.
*/
result: AuthResult;
}
/**
* Hook providing operations and corresponding state for authenticating with an
* Atlas App with Email/Password. It also contains operations related to
* Email/Password authentication, such as resetting password and confirming a user.
*
* The {@link AuthResult} values returned from this hook (e.g. `state`, `pending`, etc.) are
* shared across all components under a given `AppProvider`, as only one operation can be in
* progress at a given time (i.e. we will store the values on the context). This means that,
* for example, multiple components can use the `useEmailPasswordAuth` hook to access
* `result.pending` to render a spinner when login is in progress, without
* needing to pass that state around or store it somewhere global in their app
* code.
* @returns An object containing operations and state related to Email/Password authentication.
*/
export declare function useEmailPasswordAuth(): UseEmailPasswordAuth;
export {};
//# sourceMappingURL=useEmailPasswordAuth.d.ts.map