Module supertokens_python.recipe.emailpassword.interfaces
Expand source code
# Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.
#
# This software is licensed under the Apache License, Version 2.0 (the
# "License") as published by the Apache Software Foundation.
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Dict, List, Union
from xmlrpc.client import boolean
from ..emailverification.interfaces import \
RecipeInterface as EmailVerificationRecipeInterface
from typing_extensions import Literal
if TYPE_CHECKING:
from supertokens_python.framework import BaseRequest, BaseResponse
from supertokens_python.recipe.session import SessionContainer
from .types import FormField, User
from .utils import EmailPasswordConfig
class SignUpResult(ABC):
def __init__(
self, status: Literal['OK', 'EMAIL_ALREADY_EXISTS_ERROR'], user: Union[User, None]):
self.status = status
self.is_ok = False
self.is_email_already_exists_error = False
self.user = user
class SignUpOkResult(SignUpResult):
def __init__(self, user: User):
super().__init__('OK', user)
self.is_ok = True
self.is_email_already_exists_error = False
class SignUpEmailAlreadyExistsErrorResult(SignUpResult):
def __init__(self):
super().__init__('EMAIL_ALREADY_EXISTS_ERROR', None)
self.is_ok = False
self.is_email_already_exists_error = True
class SignInResult(ABC):
def __init__(
self, status: Literal['OK', 'WRONG_CREDENTIALS_ERROR'], user: Union[User, None]):
self.status: Literal['OK', 'WRONG_CREDENTIALS_ERROR'] = status
self.is_ok = False
self.is_wrong_credentials_error: boolean = False
self.user: Union[User, None] = user
class SignInOkResult(SignInResult):
def __init__(self, user: User):
super().__init__('OK', user)
self.is_ok = True
self.is_wrong_credentials_error = False
class SignInWrongCredentialsErrorResult(SignInResult):
def __init__(self):
super().__init__('WRONG_CREDENTIALS_ERROR', None)
self.is_ok = False
self.is_wrong_credentials_error = True
class CreateResetPasswordResult(ABC):
def __init__(
self, status: Literal['OK', 'UNKNOWN_USER_ID_ERROR'], token: Union[str, None]):
self.status = status
self.is_ok = False
self.is_unknown_user_id_error = False
self.token = token
class CreateResetPasswordOkResult(CreateResetPasswordResult):
def __init__(self, token: str):
super().__init__('OK', token)
self.is_ok = True
self.is_unknown_user_id_error = False
class CreateResetPasswordWrongUserIdErrorResult(CreateResetPasswordResult):
def __init__(self):
super().__init__('UNKNOWN_USER_ID_ERROR', None)
self.is_ok = False
self.is_unknown_user_id_error = True
class ResetPasswordUsingTokenResult(ABC):
def __init__(self, status: Literal['OK',
'RESET_PASSWORD_INVALID_TOKEN_ERROR'], user_id: Union[None, str] = None):
self.status: Literal['OK',
'RESET_PASSWORD_INVALID_TOKEN_ERROR'] = status
self.is_ok: bool = False
self.user_id: Union[None, str] = user_id
self.is_reset_password_invalid_token_error: bool = False
class ResetPasswordUsingTokenOkResult(ResetPasswordUsingTokenResult):
def __init__(self, user_id: Union[None, str]):
super().__init__('OK', user_id)
self.is_ok = True
self.is_reset_password_invalid_token_error = False
class ResetPasswordUsingTokenWrongUserIdErrorResult(
ResetPasswordUsingTokenResult):
def __init__(self):
super().__init__('RESET_PASSWORD_INVALID_TOKEN_ERROR')
self.is_ok = False
self.is_reset_password_invalid_token_error = True
class UpdateEmailOrPasswordResult(ABC):
def __init__(
self, status: Literal['OK', 'UNKNOWN_USER_ID_ERROR', 'EMAIL_ALREADY_EXISTS_ERROR']):
self.status = status
self.is_ok = False
self.is_email_already_exists_error = False
self.is_unknown_user_id_error = False
class UpdateEmailOrPasswordOkResult(UpdateEmailOrPasswordResult):
def __init__(self):
super().__init__('OK')
self.is_ok = True
self.is_email_already_exists_error = False
self.is_unknown_user_id_error = False
class UpdateEmailOrPasswordEmailAlreadyExistsErrorResult(
UpdateEmailOrPasswordResult):
def __init__(self):
super().__init__('EMAIL_ALREADY_EXISTS_ERROR')
self.is_ok = False
self.is_email_already_exists_error = True
self.is_unknown_user_id_error = False
class UpdateEmailOrPasswordUnknownUserIdErrorResult(
UpdateEmailOrPasswordResult):
def __init__(self):
super().__init__('UNKNOWN_USER_ID_ERROR')
self.is_ok = False
self.is_email_already_exists_error = False
self.is_unknown_user_id_error = True
class RecipeInterface(ABC):
def __init__(self):
pass
@abstractmethod
async def get_user_by_id(self, user_id: str, user_context: Dict[str, Any]) -> Union[User, None]:
pass
@abstractmethod
async def get_user_by_email(self, email: str, user_context: Dict[str, Any]) -> Union[User, None]:
pass
@abstractmethod
async def create_reset_password_token(self, user_id: str, user_context: Dict[str, Any]) -> CreateResetPasswordResult:
pass
@abstractmethod
async def reset_password_using_token(self, token: str, new_password: str,
user_context: Dict[str, Any]) -> ResetPasswordUsingTokenResult:
pass
@abstractmethod
async def sign_in(self, email: str, password: str, user_context: Dict[str, Any]) -> SignInResult:
pass
@abstractmethod
async def sign_up(self, email: str, password: str, user_context: Dict[str, Any]) -> SignUpResult:
pass
@abstractmethod
async def update_email_or_password(self, user_id: str, email: Union[str, None],
password: Union[str, None], user_context: Dict[str, Any]) -> UpdateEmailOrPasswordResult:
pass
class APIOptions:
def __init__(self, request: BaseRequest, response: BaseResponse, recipe_id: str,
config: EmailPasswordConfig, recipe_implementation: RecipeInterface,
email_verification_recipe_implementation: EmailVerificationRecipeInterface):
self.request: BaseRequest = request
self.response: BaseResponse = response
self.recipe_id: str = recipe_id
self.config: EmailPasswordConfig = config
self.recipe_implementation: RecipeInterface = recipe_implementation
self.email_verification_recipe_implementation: EmailVerificationRecipeInterface = email_verification_recipe_implementation
class EmailVerifyPostResponse(ABC):
def __init__(
self, status: Literal['OK', 'EMAIL_VERIFICATION_INVALID_TOKEN_ERROR'], user: Union[User, None]):
self.status = status
self.is_ok = False
self.is_email_verification_invalid_token_error = False
self.user = user
def to_json(self) -> Dict[str, Any]:
return {
'status': self.status
}
class EmailVerifyPostOkResponse(EmailVerifyPostResponse):
def __init__(self, user: User):
super().__init__('OK', user)
self.is_ok = True
self.is_email_verification_invalid_token_error = False
def to_json(self) -> Dict[str, Any]:
if self.user is None:
raise Exception("Should never come here")
return {
'status': self.status,
'user': {
'id': self.user.user_id,
'email': self.user.email
}
}
class EmailVerifyPostInvalidTokenErrorResponse(EmailVerifyPostResponse):
def __init__(self):
super().__init__('EMAIL_VERIFICATION_INVALID_TOKEN_ERROR', None)
self.is_ok = False
self.is_email_verification_invalid_token_error = True
class IsEmailVerifiedGetResponse(ABC):
def __init__(self, status: Literal['OK']):
self.status = status
self.is_ok = False
def to_json(self) -> Dict[str, Any]:
return {
'status': self.status
}
class IsEmailVerifiedGetOkResponse(IsEmailVerifiedGetResponse):
def __init__(self, is_verified: bool):
super().__init__('OK')
self.is_verified = is_verified
self.is_ok = True
def to_json(self) -> Dict[str, Any]:
return {
'status': self.status,
'isVerified': self.is_verified
}
class GenerateEmailVerifyTokenPostResponse(ABC):
def __init__(self, status: Literal['OK', 'EMAIL_ALREADY_VERIFIED_ERROR']):
self.status = status
self.is_ok = False
self.is_email_already_verified_error = False
def to_json(self) -> Dict[str, Any]:
return {
'status': self.status
}
class GenerateEmailVerifyTokenPostOkResponse(
GenerateEmailVerifyTokenPostResponse):
def __init__(self):
super().__init__('OK')
self.is_ok = True
self.is_email_already_verified_error = False
class GenerateEmailVerifyTokenPostEmailAlreadyVerifiedErrorResponse(
GenerateEmailVerifyTokenPostResponse):
def __init__(self):
super().__init__('EMAIL_ALREADY_VERIFIED_ERROR')
self.is_ok = False
self.is_email_already_verified_error = True
class EmailExistsGetResponse(ABC):
def __init__(self, status: Literal['OK'], exists: bool):
self.status = status
self.exists = exists
def to_json(self) -> Dict[str, Any]:
return {
'status': self.status,
'exists': self.exists
}
class EmailExistsGetOkResponse(EmailExistsGetResponse):
def __init__(self, exists: bool):
super().__init__('OK', exists)
class GeneratePasswordResetTokenPostResponse(ABC):
def __init__(self, status: Literal['OK']):
self.status = status
def to_json(self) -> Dict[str, Any]:
return {
'status': self.status
}
class GeneratePasswordResetTokenPostOkResponse(
GeneratePasswordResetTokenPostResponse):
def __init__(self):
super().__init__('OK')
class PasswordResetPostResponse(ABC):
def __init__(self, status: Literal['OK',
'RESET_PASSWORD_INVALID_TOKEN_ERROR'], user_id: Union[str, None] = None):
self.user_id: Union[str, None] = user_id
self.status: Literal['OK',
'RESET_PASSWORD_INVALID_TOKEN_ERROR'] = status
def to_json(self) -> Dict[str, Any]:
return {
'status': self.status
}
class PasswordResetPostOkResponse(PasswordResetPostResponse):
def __init__(self, user_id: Union[str, None]):
super().__init__('OK', user_id)
class PasswordResetPostInvalidTokenResponse(PasswordResetPostResponse):
def __init__(self):
super().__init__('RESET_PASSWORD_INVALID_TOKEN_ERROR')
class SignInPostResponse(ABC):
def __init__(
self, status: Literal['OK', 'WRONG_CREDENTIALS_ERROR'],
user: Union[User, None] = None,
session: Union[SessionContainer, None] = None):
self.type = 'emailpassword'
self.is_ok: bool = False
self.is_wrong_credentials_error: bool = False
self.status: Literal['OK', 'WRONG_CREDENTIALS_ERROR'] = status
self.user: Union[User, None] = user
self.session: Union[SessionContainer, None] = session
def to_json(self) -> Dict[str, Any]:
response = {
'status': self.status
}
if self.user is not None:
response = {
'user': {
'id': self.user.user_id,
'email': self.user.email,
'timeJoined': self.user.time_joined
},
**response
}
return response
class SignInPostOkResponse(SignInPostResponse):
def __init__(self, user: User, session: SessionContainer):
super().__init__('OK', user, session)
self.is_ok = True
class SignInPostWrongCredentialsErrorResponse(SignInPostResponse):
def __init__(self):
super().__init__('WRONG_CREDENTIALS_ERROR')
self.is_wrong_credentials_error = True
class SignUpPostResponse(ABC):
def __init__(
self, status: Literal['OK', 'EMAIL_ALREADY_EXISTS_ERROR'],
user: Union[User, None] = None,
session: Union[SessionContainer, None] = None):
self.type = 'emailpassword'
self.is_ok: bool = False
self.is_email_already_exists_error: bool = False
self.status: Literal['OK', 'EMAIL_ALREADY_EXISTS_ERROR'] = status
self.user: Union[User, None] = user
self.session: Union[SessionContainer, None] = session
def to_json(self) -> Dict[str, Any]:
response = {
'status': self.status
}
if self.user is not None:
response = {
'user': {
'id': self.user.user_id,
'email': self.user.email,
'timeJoined': self.user.time_joined
},
**response
}
return response
class SignUpPostOkResponse(SignUpPostResponse):
def __init__(self, user: User, session: SessionContainer):
super().__init__('OK', user, session)
self.is_ok = True
class SignUpPostEmailAlreadyExistsErrorResponse(SignUpPostResponse):
def __init__(self):
super().__init__('EMAIL_ALREADY_EXISTS_ERROR')
self.is_email_already_exists_error = True
class APIInterface:
def __init__(self):
self.disable_email_exists_get = False
self.disable_generate_password_reset_token_post = False
self.disable_password_reset_post = False
self.disable_sign_in_post = False
self.disable_sign_up_post = False
@abstractmethod
async def email_exists_get(self, email: str, api_options: APIOptions, user_context: Dict[str, Any]) -> EmailExistsGetResponse:
pass
@abstractmethod
async def generate_password_reset_token_post(self, form_fields: List[FormField],
api_options: APIOptions,
user_context: Dict[str, Any]) -> GeneratePasswordResetTokenPostResponse:
pass
@abstractmethod
async def password_reset_post(self, form_fields: List[FormField], token: str,
api_options: APIOptions, user_context: Dict[str, Any]) -> PasswordResetPostResponse:
pass
@abstractmethod
async def sign_in_post(self, form_fields: List[FormField],
api_options: APIOptions,
user_context: Dict[str, Any]) -> SignInPostResponse:
pass
@abstractmethod
async def sign_up_post(self, form_fields: List[FormField],
api_options: APIOptions,
user_context: Dict[str, Any]) -> SignUpPostResponse:
pass
Classes
class APIInterface
-
Expand source code
class APIInterface: def __init__(self): self.disable_email_exists_get = False self.disable_generate_password_reset_token_post = False self.disable_password_reset_post = False self.disable_sign_in_post = False self.disable_sign_up_post = False @abstractmethod async def email_exists_get(self, email: str, api_options: APIOptions, user_context: Dict[str, Any]) -> EmailExistsGetResponse: pass @abstractmethod async def generate_password_reset_token_post(self, form_fields: List[FormField], api_options: APIOptions, user_context: Dict[str, Any]) -> GeneratePasswordResetTokenPostResponse: pass @abstractmethod async def password_reset_post(self, form_fields: List[FormField], token: str, api_options: APIOptions, user_context: Dict[str, Any]) -> PasswordResetPostResponse: pass @abstractmethod async def sign_in_post(self, form_fields: List[FormField], api_options: APIOptions, user_context: Dict[str, Any]) -> SignInPostResponse: pass @abstractmethod async def sign_up_post(self, form_fields: List[FormField], api_options: APIOptions, user_context: Dict[str, Any]) -> SignUpPostResponse: pass
Subclasses
Methods
async def email_exists_get(self, email: str, api_options: APIOptions, user_context: Dict[str, Any]) ‑> EmailExistsGetResponse
-
Expand source code
@abstractmethod async def email_exists_get(self, email: str, api_options: APIOptions, user_context: Dict[str, Any]) -> EmailExistsGetResponse: pass
async def generate_password_reset_token_post(self, form_fields: List[FormField], api_options: APIOptions, user_context: Dict[str, Any]) ‑> GeneratePasswordResetTokenPostResponse
-
Expand source code
@abstractmethod async def generate_password_reset_token_post(self, form_fields: List[FormField], api_options: APIOptions, user_context: Dict[str, Any]) -> GeneratePasswordResetTokenPostResponse: pass
async def password_reset_post(self, form_fields: List[FormField], token: str, api_options: APIOptions, user_context: Dict[str, Any]) ‑> PasswordResetPostResponse
-
Expand source code
@abstractmethod async def password_reset_post(self, form_fields: List[FormField], token: str, api_options: APIOptions, user_context: Dict[str, Any]) -> PasswordResetPostResponse: pass
async def sign_in_post(self, form_fields: List[FormField], api_options: APIOptions, user_context: Dict[str, Any]) ‑> SignInPostResponse
-
Expand source code
@abstractmethod async def sign_in_post(self, form_fields: List[FormField], api_options: APIOptions, user_context: Dict[str, Any]) -> SignInPostResponse: pass
async def sign_up_post(self, form_fields: List[FormField], api_options: APIOptions, user_context: Dict[str, Any]) ‑> SignUpPostResponse
-
Expand source code
@abstractmethod async def sign_up_post(self, form_fields: List[FormField], api_options: APIOptions, user_context: Dict[str, Any]) -> SignUpPostResponse: pass
class APIOptions (request: BaseRequest, response: BaseResponse, recipe_id: str, config: EmailPasswordConfig, recipe_implementation: RecipeInterface, email_verification_recipe_implementation: EmailVerificationRecipeInterface)
-
Expand source code
class APIOptions: def __init__(self, request: BaseRequest, response: BaseResponse, recipe_id: str, config: EmailPasswordConfig, recipe_implementation: RecipeInterface, email_verification_recipe_implementation: EmailVerificationRecipeInterface): self.request: BaseRequest = request self.response: BaseResponse = response self.recipe_id: str = recipe_id self.config: EmailPasswordConfig = config self.recipe_implementation: RecipeInterface = recipe_implementation self.email_verification_recipe_implementation: EmailVerificationRecipeInterface = email_verification_recipe_implementation
class CreateResetPasswordOkResult (token: str)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class CreateResetPasswordOkResult(CreateResetPasswordResult): def __init__(self, token: str): super().__init__('OK', token) self.is_ok = True self.is_unknown_user_id_error = False
Ancestors
- CreateResetPasswordResult
- abc.ABC
class CreateResetPasswordResult (status: "Literal['OK', 'UNKNOWN_USER_ID_ERROR']", token: Union[str, None])
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class CreateResetPasswordResult(ABC): def __init__( self, status: Literal['OK', 'UNKNOWN_USER_ID_ERROR'], token: Union[str, None]): self.status = status self.is_ok = False self.is_unknown_user_id_error = False self.token = token
Ancestors
- abc.ABC
Subclasses
class CreateResetPasswordWrongUserIdErrorResult
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class CreateResetPasswordWrongUserIdErrorResult(CreateResetPasswordResult): def __init__(self): super().__init__('UNKNOWN_USER_ID_ERROR', None) self.is_ok = False self.is_unknown_user_id_error = True
Ancestors
- CreateResetPasswordResult
- abc.ABC
class EmailExistsGetOkResponse (exists: bool)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class EmailExistsGetOkResponse(EmailExistsGetResponse): def __init__(self, exists: bool): super().__init__('OK', exists)
Ancestors
- EmailExistsGetResponse
- abc.ABC
class EmailExistsGetResponse (status: "Literal['OK']", exists: bool)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class EmailExistsGetResponse(ABC): def __init__(self, status: Literal['OK'], exists: bool): self.status = status self.exists = exists def to_json(self) -> Dict[str, Any]: return { 'status': self.status, 'exists': self.exists }
Ancestors
- abc.ABC
Subclasses
Methods
def to_json(self) ‑> Dict[str, Any]
-
Expand source code
def to_json(self) -> Dict[str, Any]: return { 'status': self.status, 'exists': self.exists }
class EmailVerifyPostInvalidTokenErrorResponse
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class EmailVerifyPostInvalidTokenErrorResponse(EmailVerifyPostResponse): def __init__(self): super().__init__('EMAIL_VERIFICATION_INVALID_TOKEN_ERROR', None) self.is_ok = False self.is_email_verification_invalid_token_error = True
Ancestors
- EmailVerifyPostResponse
- abc.ABC
class EmailVerifyPostOkResponse (user: User)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class EmailVerifyPostOkResponse(EmailVerifyPostResponse): def __init__(self, user: User): super().__init__('OK', user) self.is_ok = True self.is_email_verification_invalid_token_error = False def to_json(self) -> Dict[str, Any]: if self.user is None: raise Exception("Should never come here") return { 'status': self.status, 'user': { 'id': self.user.user_id, 'email': self.user.email } }
Ancestors
- EmailVerifyPostResponse
- abc.ABC
Methods
def to_json(self) ‑> Dict[str, Any]
-
Expand source code
def to_json(self) -> Dict[str, Any]: if self.user is None: raise Exception("Should never come here") return { 'status': self.status, 'user': { 'id': self.user.user_id, 'email': self.user.email } }
class EmailVerifyPostResponse (status: "Literal['OK', 'EMAIL_VERIFICATION_INVALID_TOKEN_ERROR']", user: Union[User, None])
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class EmailVerifyPostResponse(ABC): def __init__( self, status: Literal['OK', 'EMAIL_VERIFICATION_INVALID_TOKEN_ERROR'], user: Union[User, None]): self.status = status self.is_ok = False self.is_email_verification_invalid_token_error = False self.user = user def to_json(self) -> Dict[str, Any]: return { 'status': self.status }
Ancestors
- abc.ABC
Subclasses
Methods
def to_json(self) ‑> Dict[str, Any]
-
Expand source code
def to_json(self) -> Dict[str, Any]: return { 'status': self.status }
class GenerateEmailVerifyTokenPostEmailAlreadyVerifiedErrorResponse
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class GenerateEmailVerifyTokenPostEmailAlreadyVerifiedErrorResponse( GenerateEmailVerifyTokenPostResponse): def __init__(self): super().__init__('EMAIL_ALREADY_VERIFIED_ERROR') self.is_ok = False self.is_email_already_verified_error = True
Ancestors
class GenerateEmailVerifyTokenPostOkResponse
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class GenerateEmailVerifyTokenPostOkResponse( GenerateEmailVerifyTokenPostResponse): def __init__(self): super().__init__('OK') self.is_ok = True self.is_email_already_verified_error = False
Ancestors
class GenerateEmailVerifyTokenPostResponse (status: "Literal['OK', 'EMAIL_ALREADY_VERIFIED_ERROR']")
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class GenerateEmailVerifyTokenPostResponse(ABC): def __init__(self, status: Literal['OK', 'EMAIL_ALREADY_VERIFIED_ERROR']): self.status = status self.is_ok = False self.is_email_already_verified_error = False def to_json(self) -> Dict[str, Any]: return { 'status': self.status }
Ancestors
- abc.ABC
Subclasses
- GenerateEmailVerifyTokenPostEmailAlreadyVerifiedErrorResponse
- GenerateEmailVerifyTokenPostOkResponse
Methods
def to_json(self) ‑> Dict[str, Any]
-
Expand source code
def to_json(self) -> Dict[str, Any]: return { 'status': self.status }
class GeneratePasswordResetTokenPostOkResponse
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class GeneratePasswordResetTokenPostOkResponse( GeneratePasswordResetTokenPostResponse): def __init__(self): super().__init__('OK')
Ancestors
class GeneratePasswordResetTokenPostResponse (status: "Literal['OK']")
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class GeneratePasswordResetTokenPostResponse(ABC): def __init__(self, status: Literal['OK']): self.status = status def to_json(self) -> Dict[str, Any]: return { 'status': self.status }
Ancestors
- abc.ABC
Subclasses
Methods
def to_json(self) ‑> Dict[str, Any]
-
Expand source code
def to_json(self) -> Dict[str, Any]: return { 'status': self.status }
class IsEmailVerifiedGetOkResponse (is_verified: bool)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class IsEmailVerifiedGetOkResponse(IsEmailVerifiedGetResponse): def __init__(self, is_verified: bool): super().__init__('OK') self.is_verified = is_verified self.is_ok = True def to_json(self) -> Dict[str, Any]: return { 'status': self.status, 'isVerified': self.is_verified }
Ancestors
- IsEmailVerifiedGetResponse
- abc.ABC
Methods
def to_json(self) ‑> Dict[str, Any]
-
Expand source code
def to_json(self) -> Dict[str, Any]: return { 'status': self.status, 'isVerified': self.is_verified }
class IsEmailVerifiedGetResponse (status: "Literal['OK']")
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class IsEmailVerifiedGetResponse(ABC): def __init__(self, status: Literal['OK']): self.status = status self.is_ok = False def to_json(self) -> Dict[str, Any]: return { 'status': self.status }
Ancestors
- abc.ABC
Subclasses
Methods
def to_json(self) ‑> Dict[str, Any]
-
Expand source code
def to_json(self) -> Dict[str, Any]: return { 'status': self.status }
class PasswordResetPostInvalidTokenResponse
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class PasswordResetPostInvalidTokenResponse(PasswordResetPostResponse): def __init__(self): super().__init__('RESET_PASSWORD_INVALID_TOKEN_ERROR')
Ancestors
- PasswordResetPostResponse
- abc.ABC
class PasswordResetPostOkResponse (user_id: Union[str, None])
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class PasswordResetPostOkResponse(PasswordResetPostResponse): def __init__(self, user_id: Union[str, None]): super().__init__('OK', user_id)
Ancestors
- PasswordResetPostResponse
- abc.ABC
class PasswordResetPostResponse (status: "Literal['OK', 'RESET_PASSWORD_INVALID_TOKEN_ERROR']", user_id: Union[str, None] = None)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class PasswordResetPostResponse(ABC): def __init__(self, status: Literal['OK', 'RESET_PASSWORD_INVALID_TOKEN_ERROR'], user_id: Union[str, None] = None): self.user_id: Union[str, None] = user_id self.status: Literal['OK', 'RESET_PASSWORD_INVALID_TOKEN_ERROR'] = status def to_json(self) -> Dict[str, Any]: return { 'status': self.status }
Ancestors
- abc.ABC
Subclasses
Methods
def to_json(self) ‑> Dict[str, Any]
-
Expand source code
def to_json(self) -> Dict[str, Any]: return { 'status': self.status }
class RecipeInterface
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class RecipeInterface(ABC): def __init__(self): pass @abstractmethod async def get_user_by_id(self, user_id: str, user_context: Dict[str, Any]) -> Union[User, None]: pass @abstractmethod async def get_user_by_email(self, email: str, user_context: Dict[str, Any]) -> Union[User, None]: pass @abstractmethod async def create_reset_password_token(self, user_id: str, user_context: Dict[str, Any]) -> CreateResetPasswordResult: pass @abstractmethod async def reset_password_using_token(self, token: str, new_password: str, user_context: Dict[str, Any]) -> ResetPasswordUsingTokenResult: pass @abstractmethod async def sign_in(self, email: str, password: str, user_context: Dict[str, Any]) -> SignInResult: pass @abstractmethod async def sign_up(self, email: str, password: str, user_context: Dict[str, Any]) -> SignUpResult: pass @abstractmethod async def update_email_or_password(self, user_id: str, email: Union[str, None], password: Union[str, None], user_context: Dict[str, Any]) -> UpdateEmailOrPasswordResult: pass
Ancestors
- abc.ABC
Subclasses
Methods
async def create_reset_password_token(self, user_id: str, user_context: Dict[str, Any]) ‑> CreateResetPasswordResult
-
Expand source code
@abstractmethod async def create_reset_password_token(self, user_id: str, user_context: Dict[str, Any]) -> CreateResetPasswordResult: pass
async def get_user_by_email(self, email: str, user_context: Dict[str, Any]) ‑> Union[User, None]
-
Expand source code
@abstractmethod async def get_user_by_email(self, email: str, user_context: Dict[str, Any]) -> Union[User, None]: pass
async def get_user_by_id(self, user_id: str, user_context: Dict[str, Any]) ‑> Union[User, None]
-
Expand source code
@abstractmethod async def get_user_by_id(self, user_id: str, user_context: Dict[str, Any]) -> Union[User, None]: pass
async def reset_password_using_token(self, token: str, new_password: str, user_context: Dict[str, Any]) ‑> ResetPasswordUsingTokenResult
-
Expand source code
@abstractmethod async def reset_password_using_token(self, token: str, new_password: str, user_context: Dict[str, Any]) -> ResetPasswordUsingTokenResult: pass
async def sign_in(self, email: str, password: str, user_context: Dict[str, Any]) ‑> SignInResult
-
Expand source code
@abstractmethod async def sign_in(self, email: str, password: str, user_context: Dict[str, Any]) -> SignInResult: pass
async def sign_up(self, email: str, password: str, user_context: Dict[str, Any]) ‑> SignUpResult
-
Expand source code
@abstractmethod async def sign_up(self, email: str, password: str, user_context: Dict[str, Any]) -> SignUpResult: pass
async def update_email_or_password(self, user_id: str, email: Union[str, None], password: Union[str, None], user_context: Dict[str, Any]) ‑> UpdateEmailOrPasswordResult
-
Expand source code
@abstractmethod async def update_email_or_password(self, user_id: str, email: Union[str, None], password: Union[str, None], user_context: Dict[str, Any]) -> UpdateEmailOrPasswordResult: pass
class ResetPasswordUsingTokenOkResult (user_id: Union[None, str])
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class ResetPasswordUsingTokenOkResult(ResetPasswordUsingTokenResult): def __init__(self, user_id: Union[None, str]): super().__init__('OK', user_id) self.is_ok = True self.is_reset_password_invalid_token_error = False
Ancestors
- ResetPasswordUsingTokenResult
- abc.ABC
class ResetPasswordUsingTokenResult (status: "Literal['OK', 'RESET_PASSWORD_INVALID_TOKEN_ERROR']", user_id: Union[None, str] = None)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class ResetPasswordUsingTokenResult(ABC): def __init__(self, status: Literal['OK', 'RESET_PASSWORD_INVALID_TOKEN_ERROR'], user_id: Union[None, str] = None): self.status: Literal['OK', 'RESET_PASSWORD_INVALID_TOKEN_ERROR'] = status self.is_ok: bool = False self.user_id: Union[None, str] = user_id self.is_reset_password_invalid_token_error: bool = False
Ancestors
- abc.ABC
Subclasses
class ResetPasswordUsingTokenWrongUserIdErrorResult
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class ResetPasswordUsingTokenWrongUserIdErrorResult( ResetPasswordUsingTokenResult): def __init__(self): super().__init__('RESET_PASSWORD_INVALID_TOKEN_ERROR') self.is_ok = False self.is_reset_password_invalid_token_error = True
Ancestors
- ResetPasswordUsingTokenResult
- abc.ABC
class SignInOkResult (user: User)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignInOkResult(SignInResult): def __init__(self, user: User): super().__init__('OK', user) self.is_ok = True self.is_wrong_credentials_error = False
Ancestors
- SignInResult
- abc.ABC
class SignInPostOkResponse (user: User, session: SessionContainer)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignInPostOkResponse(SignInPostResponse): def __init__(self, user: User, session: SessionContainer): super().__init__('OK', user, session) self.is_ok = True
Ancestors
- SignInPostResponse
- abc.ABC
class SignInPostResponse (status: "Literal['OK', 'WRONG_CREDENTIALS_ERROR']", user: Union[User, None] = None, session: Union[SessionContainer, None] = None)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignInPostResponse(ABC): def __init__( self, status: Literal['OK', 'WRONG_CREDENTIALS_ERROR'], user: Union[User, None] = None, session: Union[SessionContainer, None] = None): self.type = 'emailpassword' self.is_ok: bool = False self.is_wrong_credentials_error: bool = False self.status: Literal['OK', 'WRONG_CREDENTIALS_ERROR'] = status self.user: Union[User, None] = user self.session: Union[SessionContainer, None] = session def to_json(self) -> Dict[str, Any]: response = { 'status': self.status } if self.user is not None: response = { 'user': { 'id': self.user.user_id, 'email': self.user.email, 'timeJoined': self.user.time_joined }, **response } return response
Ancestors
- abc.ABC
Subclasses
Methods
def to_json(self) ‑> Dict[str, Any]
-
Expand source code
def to_json(self) -> Dict[str, Any]: response = { 'status': self.status } if self.user is not None: response = { 'user': { 'id': self.user.user_id, 'email': self.user.email, 'timeJoined': self.user.time_joined }, **response } return response
class SignInPostWrongCredentialsErrorResponse
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignInPostWrongCredentialsErrorResponse(SignInPostResponse): def __init__(self): super().__init__('WRONG_CREDENTIALS_ERROR') self.is_wrong_credentials_error = True
Ancestors
- SignInPostResponse
- abc.ABC
class SignInResult (status: "Literal['OK', 'WRONG_CREDENTIALS_ERROR']", user: Union[User, None])
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignInResult(ABC): def __init__( self, status: Literal['OK', 'WRONG_CREDENTIALS_ERROR'], user: Union[User, None]): self.status: Literal['OK', 'WRONG_CREDENTIALS_ERROR'] = status self.is_ok = False self.is_wrong_credentials_error: boolean = False self.user: Union[User, None] = user
Ancestors
- abc.ABC
Subclasses
class SignInWrongCredentialsErrorResult
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignInWrongCredentialsErrorResult(SignInResult): def __init__(self): super().__init__('WRONG_CREDENTIALS_ERROR', None) self.is_ok = False self.is_wrong_credentials_error = True
Ancestors
- SignInResult
- abc.ABC
class SignUpEmailAlreadyExistsErrorResult
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignUpEmailAlreadyExistsErrorResult(SignUpResult): def __init__(self): super().__init__('EMAIL_ALREADY_EXISTS_ERROR', None) self.is_ok = False self.is_email_already_exists_error = True
Ancestors
- SignUpResult
- abc.ABC
class SignUpOkResult (user: User)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignUpOkResult(SignUpResult): def __init__(self, user: User): super().__init__('OK', user) self.is_ok = True self.is_email_already_exists_error = False
Ancestors
- SignUpResult
- abc.ABC
class SignUpPostEmailAlreadyExistsErrorResponse
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignUpPostEmailAlreadyExistsErrorResponse(SignUpPostResponse): def __init__(self): super().__init__('EMAIL_ALREADY_EXISTS_ERROR') self.is_email_already_exists_error = True
Ancestors
- SignUpPostResponse
- abc.ABC
class SignUpPostOkResponse (user: User, session: SessionContainer)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignUpPostOkResponse(SignUpPostResponse): def __init__(self, user: User, session: SessionContainer): super().__init__('OK', user, session) self.is_ok = True
Ancestors
- SignUpPostResponse
- abc.ABC
class SignUpPostResponse (status: "Literal['OK', 'EMAIL_ALREADY_EXISTS_ERROR']", user: Union[User, None] = None, session: Union[SessionContainer, None] = None)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignUpPostResponse(ABC): def __init__( self, status: Literal['OK', 'EMAIL_ALREADY_EXISTS_ERROR'], user: Union[User, None] = None, session: Union[SessionContainer, None] = None): self.type = 'emailpassword' self.is_ok: bool = False self.is_email_already_exists_error: bool = False self.status: Literal['OK', 'EMAIL_ALREADY_EXISTS_ERROR'] = status self.user: Union[User, None] = user self.session: Union[SessionContainer, None] = session def to_json(self) -> Dict[str, Any]: response = { 'status': self.status } if self.user is not None: response = { 'user': { 'id': self.user.user_id, 'email': self.user.email, 'timeJoined': self.user.time_joined }, **response } return response
Ancestors
- abc.ABC
Subclasses
Methods
def to_json(self) ‑> Dict[str, Any]
-
Expand source code
def to_json(self) -> Dict[str, Any]: response = { 'status': self.status } if self.user is not None: response = { 'user': { 'id': self.user.user_id, 'email': self.user.email, 'timeJoined': self.user.time_joined }, **response } return response
class SignUpResult (status: "Literal['OK', 'EMAIL_ALREADY_EXISTS_ERROR']", user: Union[User, None])
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class SignUpResult(ABC): def __init__( self, status: Literal['OK', 'EMAIL_ALREADY_EXISTS_ERROR'], user: Union[User, None]): self.status = status self.is_ok = False self.is_email_already_exists_error = False self.user = user
Ancestors
- abc.ABC
Subclasses
class UpdateEmailOrPasswordEmailAlreadyExistsErrorResult
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class UpdateEmailOrPasswordEmailAlreadyExistsErrorResult( UpdateEmailOrPasswordResult): def __init__(self): super().__init__('EMAIL_ALREADY_EXISTS_ERROR') self.is_ok = False self.is_email_already_exists_error = True self.is_unknown_user_id_error = False
Ancestors
- UpdateEmailOrPasswordResult
- abc.ABC
class UpdateEmailOrPasswordOkResult
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class UpdateEmailOrPasswordOkResult(UpdateEmailOrPasswordResult): def __init__(self): super().__init__('OK') self.is_ok = True self.is_email_already_exists_error = False self.is_unknown_user_id_error = False
Ancestors
- UpdateEmailOrPasswordResult
- abc.ABC
class UpdateEmailOrPasswordResult (status: "Literal['OK', 'UNKNOWN_USER_ID_ERROR', 'EMAIL_ALREADY_EXISTS_ERROR']")
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class UpdateEmailOrPasswordResult(ABC): def __init__( self, status: Literal['OK', 'UNKNOWN_USER_ID_ERROR', 'EMAIL_ALREADY_EXISTS_ERROR']): self.status = status self.is_ok = False self.is_email_already_exists_error = False self.is_unknown_user_id_error = False
Ancestors
- abc.ABC
Subclasses
class UpdateEmailOrPasswordUnknownUserIdErrorResult
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class UpdateEmailOrPasswordUnknownUserIdErrorResult( UpdateEmailOrPasswordResult): def __init__(self): super().__init__('UNKNOWN_USER_ID_ERROR') self.is_ok = False self.is_email_already_exists_error = False self.is_unknown_user_id_error = True
Ancestors
- UpdateEmailOrPasswordResult
- abc.ABC