from __future__ import annotations
from onegov.core.security import Public
from onegov.fsi import _
from onegov.fsi.app import FsiApp
from onegov.town6.views.auth import town_handle_login as handle_login_base
from onegov.user import Auth
from onegov.user.forms import LoginForm
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from onegov.core.types import RenderData
from onegov.fsi.request import FsiRequest
from onegov.user.forms.login import LoginData
from webob import Response
@FsiApp.form(
model=Auth,
name='login',
template='login.pt',
permission=Public,
form=FsiLoginForm
)
[docs]
def handle_login(
self: Auth,
request: FsiRequest,
form: FsiLoginForm
) -> RenderData | Response:
# custom default redirect
if self.to == '/':
self.to = '/fsi/courses'
# custom username handle
form.username.label.text = request.translate(
_('E-Mail Address / Username / Shortcut'))
return handle_login_base(self, request, form)