mail notification
This commit is contained in:
@@ -96,6 +96,8 @@ def create_user(
|
||||
garmin_email: str = Form(""),
|
||||
garmin_password: str = Form(""),
|
||||
enabled: str | None = Form(None),
|
||||
notify_email_enabled: str | None = Form(None),
|
||||
notification_email: str = Form(""),
|
||||
):
|
||||
require_admin(request)
|
||||
validate_csrf(request, csrf_token)
|
||||
@@ -110,7 +112,11 @@ def create_user(
|
||||
garmin_email=garmin_email,
|
||||
garmin_password=garmin_password,
|
||||
enabled=enabled is not None,
|
||||
notify_email_enabled=notify_email_enabled is not None,
|
||||
notification_email=notification_email,
|
||||
)
|
||||
if form.notify_email_enabled:
|
||||
_require_non_empty(form.notification_email, "notification_email")
|
||||
cipher = _cipher(request)
|
||||
with request.app.state.session_factory() as session:
|
||||
repository = UserRepository(session)
|
||||
@@ -121,6 +127,8 @@ def create_user(
|
||||
mywhoosh_password_enc=cipher.encrypt(form.mywhoosh_password),
|
||||
garmin_email_enc=cipher.encrypt(form.garmin_email.strip()),
|
||||
garmin_password_enc=cipher.encrypt(form.garmin_password),
|
||||
notify_email_enabled=form.notify_email_enabled,
|
||||
notification_email=form.notification_email.strip() or None,
|
||||
)
|
||||
user_id = user.id
|
||||
return RedirectResponse(f"/users/{user_id}", status_code=303)
|
||||
@@ -175,6 +183,8 @@ def update_user(
|
||||
garmin_email: str = Form(""),
|
||||
garmin_password: str = Form(""),
|
||||
enabled: str | None = Form(None),
|
||||
notify_email_enabled: str | None = Form(None),
|
||||
notification_email: str = Form(""),
|
||||
):
|
||||
require_admin(request)
|
||||
validate_csrf(request, csrf_token)
|
||||
@@ -187,7 +197,11 @@ def update_user(
|
||||
garmin_email=garmin_email,
|
||||
garmin_password=garmin_password,
|
||||
enabled=enabled is not None,
|
||||
notify_email_enabled=notify_email_enabled is not None,
|
||||
notification_email=notification_email,
|
||||
)
|
||||
if form.notify_email_enabled:
|
||||
_require_non_empty(form.notification_email, "notification_email")
|
||||
cipher = _cipher(request)
|
||||
with request.app.state.session_factory() as session:
|
||||
repository = UserRepository(session)
|
||||
@@ -197,6 +211,8 @@ def update_user(
|
||||
"enabled": form.enabled,
|
||||
"mywhoosh_email_enc": cipher.encrypt(form.mywhoosh_email.strip()),
|
||||
"garmin_email_enc": cipher.encrypt(form.garmin_email.strip()),
|
||||
"notify_email_enabled": form.notify_email_enabled,
|
||||
"notification_email": form.notification_email.strip() or None,
|
||||
}
|
||||
if form.mywhoosh_password:
|
||||
values["mywhoosh_password_enc"] = cipher.encrypt(form.mywhoosh_password)
|
||||
|
||||
Reference in New Issue
Block a user