37 lines
875 B
Python
37 lines
875 B
Python
from dataclasses import dataclass
|
|
from typing import Optional, cast
|
|
|
|
|
|
@dataclass
|
|
class SessionUser:
|
|
id: str = ""
|
|
registered_on: str = ""
|
|
name: str = ""
|
|
email: str = ""
|
|
email_verified: bool = False
|
|
phone: str = ""
|
|
phone_verified: bool = False
|
|
mfa: bool = False
|
|
|
|
|
|
@property
|
|
def is_authenticated(self) -> bool:
|
|
return True
|
|
|
|
@property
|
|
def email_verification(self) -> bool:
|
|
return self.email_verified
|
|
|
|
@property
|
|
def phone_verification(self) -> bool:
|
|
return self.phone_verification
|
|
|
|
def import_g_session(g_session:dict) -> SessionUser:
|
|
u = SessionUser(
|
|
id=g_session.get("$id"),
|
|
name=g_session.get("name"),
|
|
registered_on=g_session.get("registration"),
|
|
email=g_session.get("email"),
|
|
email_verified=g_session.get("emailVerification")
|
|
)
|
|
return u |