MCPcopy
hub / github.com/fastapi-admin/fastapi-admin / init

Method init

fastapi_admin/providers/login.py:147–165  ·  view source on GitHub ↗
(
        self,
        request: Request,
    )

Source from the content-addressed store, hash-verified

145 return templates.TemplateResponse("init.html", context={"request": request})
146
147 async def init(
148 self,
149 request: Request,
150 ):
151 exists = await self.admin_model.all().limit(1).exists()
152 if exists:
153 return self.redirect_login(request)
154 form = await request.form()
155 password = form.get("password")
156 confirm_password = form.get("confirm_password")
157 username = form.get("username")
158 if password != confirm_password:
159 return templates.TemplateResponse(
160 "init.html",
161 context={"request": request, "error": _("confirm_password_different")},
162 )
163
164 await self.create_user(username, password)
165 return self.redirect_login(request)
166
167 def redirect_login(self, request: Request):
168 return RedirectResponse(

Callers

nothing calls this directly

Calls 3

redirect_loginMethod · 0.95
create_userMethod · 0.95
_Function · 0.90

Tested by

no test coverage detected