Skip to content

Commit

Permalink
consider user language in pw reset mail (#224)
Browse files Browse the repository at this point in the history
Co-authored-by: Timo Huber <[email protected]>
  • Loading branch information
timohuber and timohuber authored Oct 6, 2023
1 parent dde9d86 commit 50cad2b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions pool/web/handler/public_login.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ let request_reset_password_post req =
let open HttpUtils in
let open Cqrs_command.Common_command.ResetPassword in
let open Message_template in
let result { Pool_context.database_label; query_language; language; _ } =
let result ({ Pool_context.database_label; query_language; _ } as context) =
let redirect_path =
path_with_language query_language "/request-reset-password"
in
Expand All @@ -163,7 +163,24 @@ let request_reset_password_post req =
match user with
| None -> Lwt_result.return ()
| Some user ->
PasswordReset.create database_label language (Tenant tenant) user
let%lwt message_language =
match query_language with
| Some lang -> Lwt.return lang
| None ->
(match%lwt Admin.user_is_admin database_label user with
| true -> Lwt.return context.Pool_context.language
| false ->
Contact.find_by_user database_label user
>|- Pool_common.Utils.failwith
||> CCResult.get_or_failwith
||> fun Contact.{ language; _ } ->
CCOption.value ~default:context.Pool_context.language language)
in
PasswordReset.create
database_label
message_language
(Tenant tenant)
user
>== handle ~tags
|>> Pool_event.handle_events ~tags database_label
in
Expand Down

0 comments on commit 50cad2b

Please sign in to comment.