Skip to main content
Version: 7.2.X

Overriding Functions

Main interface#

interface RecipeInterface {    /*     * Called to get user info based on userId    *     * @params: userId    *     * @returns: user object if a user is found for the given userId, else undefined    */    getUserById(input: { userId: string }): Promise<User | undefined>;
    /*     * Called to get user info based on email    *     * @params: email    *     * @returns: array of user object    */    getUsersByEmail(input: { email: string }): Promise<User[]>;
    /*     * Called to get user info based on thirdparty info    *     * @params: thirdPartyId: third party provider id, e.g. "google"    *          thirdPartyUserId: userId that was given by the third party provider    *     * @returns: user object if a user is found for the given userId, else undefined    */    getUserByThirdPartyInfo(input: { thirdPartyId: string; thirdPartyUserId: string }): Promise<User | undefined>;
    /*     * Called to sign-up/sign-in a user    *     * @params: email: an object containing email id and boolean stating if email is verified or not    *          thirdPartyId: third party provider id, e.g. "google"    *          thirdPartyUserId: userId that was given by the third party provider    *     * @returns: "OK": on successfully signing up the user    *           "FIELD_ERROR": error in passing thridparty fields    */    signInUp(input: {        thirdPartyId: string;        thirdPartyUserId: string;        email: {            id: string;            isVerified: boolean;        };    }): Promise<        | { status: "OK"; createdNewUser: boolean; user: User }        | {              status: "FIELD_ERROR";              error: string;          }    >;
    /*     * Called to sign-up a new user    *     * @params: email    *          password    *     * @returns: "OK": on successfully signing up the user    *           "EMAIL_ALREADY_EXISTS_ERROR": if the email is already been used    */    signUp(input: {        email: string;        password: string;    }): Promise<{ status: "OK"; user: User } | { status: "EMAIL_ALREADY_EXISTS_ERROR" }>;
    /*     * Called to sign-in a user    *     * @params: email    *          password    *     * @returns: "OK": on successfully verifying email and password    *           "WRONG_CREDENTIALS_ERROR": if password is invalid or no account info found for the given email    */    signIn(input: {        email: string;        password: string;    }): Promise<{ status: "OK"; user: User } | { status: "WRONG_CREDENTIALS_ERROR" }>;
    /*     * Called to get user info based on email address    *     * @params: email    *     * @returns: user object if a user is found for the given email, else undefined    */    getUserByEmail(input: { email: string }): Promise<User | undefined>;
    /*     * Called to generate a password reset token for the user    *     * @params: userId    *     * @returns: "OK": on successfully generating reset password token    *           "UNKNOWN_USER_ID_ERROR": if no user found for the given userId    */    createResetPasswordToken(input: {        userId: string;    }): Promise<{ status: "OK"; token: string } | { status: "UNKNOWN_USER_ID_ERROR" }>;
    /*     * Called to update password using password reset token    *     * @params: token is the password reset token    *          newPassword is the updated password    *     * @returns: "OK": on successfully updating user's password    *           "RESET_PASSWORD_INVALID_TOKEN_ERROR": if password reset token is invalid    */    resetPasswordUsingToken(input: {        token: string;        newPassword: string;    }): Promise<{ status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR" }>;
    /*     * Called to update users email or password    *     * @params: userId the user whose info you want to update    *          email is the updated email    *          password is the updated password    *     * @returns: "OK": on successfully updating    *           "UNKNOWN_USER_ID_ERROR": if the provided user did not sign up using emailpassword    *           "EMAIL_ALREADY_EXISTS_ERROR": if the provided email already belongs to another user    */    updateEmailOrPassword(input: {        userId: string;        email?: string;        password?: string;    }): Promise<{ status: "OK" | "UNKNOWN_USER_ID_ERROR" | "EMAIL_ALREADY_EXISTS_ERROR" }>;}

Supporting Types#

interface User {    id: string;    timeJoined: number;    email: string;    thirdParty?: {        id: string;        userId: string;    };}