async def password_reset(request: Request): error = request.cookies.get("error", None) message = request.cookies.get("message", None) if error: return template('pages/account/change-password.html', {'request': request, "error":json.loads(error)}) elif message: return template('pages/account/change-password.html', {'request': request, "message":json.loads(message)}) return template('pages/account/change-password.html', {'request': request})
async def register(request: Request, user: dict = Depends(ViewMixin.get_user)): if user: return RedirectResponse("/", status_code=302) error = request.cookies.get("error") if error: return template('pages/account/register.html', { "request": request, "error": json.loads(error) }) return template('pages/account/register.html', {"request": request})
async def index(request: Request, user: dict = Depends(ViewMixin.get_user_details)): if user: return template("pages/base/base.html", { "request": request, "user": user }) return template("pages/account/login.html", { "request": request, "user": user }, status_code=302)
async def service(request: Request, user: dict = Depends(ViewMixin.get_user)): async with AsyncClient() as client: data = await client.get(f"{API_WEBSITE_URL}/service") if data.status_code == 200: return template('pages/service/service.html', { 'request': request, "user": user, "service": data.json() }) return template('pages/service/service.html', { 'request': request, "user": user })
async def login(request: Request): error = request.cookies.get("error") message = request.cookies.get("message") if error: return template('pages/account/login.html', { "request": request, "error": json.loads(error) }) elif message: return template('pages/account/login.html', { "request": request, "message": json.loads(message) }) return template('pages/account/login.html', {"request": request})
async def plan(request: Request, user: dict = Depends(ViewMixin.get_user)): if user: return template('pages/plan/plan.html', { 'request': request, "user": user }) return RedirectResponse("/", status_code=302)
async def error_page(request: Request, user: dict = Depends(ViewMixin.get_user)): return template("pages/generalView/404.html", { "request": request, "user": user })
async def service(request: Request, user: dict = Depends(ViewMixin.get_user_details)): return template('pages/generalView/contact.html', { 'request': request, "user": user })
async def settings(request: Request, user: dict = Depends(ViewMixin.get_user)): return template('pages/account/settings.html', { 'request': request, "user": user })
async def changePassword(request: Request, userId:str): error = request.cookies.get("error") if error: return template('pages/account/password-reset.html', {'request': request, "userId":userId, "error":json.loads(error)}) return template('pages/account/password-reset.html', {'request': request, "userId": userId})