simple-ocpp-cs/backend/app/schemas/user.py

39 lines
916 B
Python
Raw Normal View History

import enum
2024-04-14 01:42:51 +02:00
from typing import Optional
2024-04-13 22:43:03 +02:00
from uuid import UUID
from pydantic import BaseModel, EmailStr, Field
class Role(enum.StrEnum):
MEMBER = "member"
ADMINISTRATOR = "administrator"
2024-03-28 21:23:25 +01:00
class UserBase(BaseModel):
email: EmailStr = Field(max_length=60)
2024-03-28 21:23:25 +01:00
friendly_name: str
is_active: bool
2024-04-14 01:42:51 +02:00
class UserUpdate(BaseModel):
email: Optional[str] = None
2024-04-14 01:42:51 +02:00
friendly_name: Optional[str] = None
class AdministrativeUserUpdate(UserUpdate):
2024-04-14 01:42:51 +02:00
is_active: Optional[bool] = None
2024-03-28 21:23:25 +01:00
class UserCreate(UserBase):
password: str = Field(max_length=100)
2024-03-28 21:23:25 +01:00
pass
class User(UserBase):
2024-04-13 22:43:03 +02:00
id: UUID
role: Role
2024-03-28 21:23:25 +01:00
class Config:
from_attributes = True
class PasswordUpdate(BaseModel):
old_password: str = Field(max_length=100)
new_password: str = Field(max_length=100)
class LoginRequest(BaseModel):
email: EmailStr = Field(max_length=60)
password: str = Field(max_length=100)