print_password_recovery_parameters

rewrite
Karchnu 2020-10-25 19:09:13 +01:00
parent 4b68daf016
commit 9524f969c4
1 changed files with 24 additions and 9 deletions

View File

@ -27,6 +27,7 @@ class Baguette::Configuration
property field_from : String? = nil property field_from : String? = nil
property read_only_profile_keys : Array(String) = Array(String).new property read_only_profile_keys : Array(String) = Array(String).new
property print_password_recovery_parameters : Bool = false
property verbosity : Int32 = 3 property verbosity : Int32 = 3
property print_ipc_timer : Bool = false property print_ipc_timer : Bool = false
property ipc_timer : Int32 = 30_000 property ipc_timer : Int32 = 30_000
@ -48,6 +49,8 @@ class AuthD::Service
property read_only_profile_keys = Array(String).new property read_only_profile_keys = Array(String).new
property print_password_recovery_parameters : Bool = false
@users_per_login : DODB::Index(User) @users_per_login : DODB::Index(User)
@users_per_uid : DODB::Index(User) @users_per_uid : DODB::Index(User)
@ -433,6 +436,15 @@ class AuthD::Service
mailer_activation_url = @mailer_activation_url.not_nil! mailer_activation_url = @mailer_activation_url.not_nil!
# Once the user is created and stored, we try to contact him # Once the user is created and stored, we try to contact him
if @print_password_recovery_parameters
pp! user.login,
user.contact.email.not_nil!,
mailer_field_from,
mailer_activation_url,
user.password_renew_key.not_nil!
end
unless Process.run("password-recovery-mailer", [ unless Process.run("password-recovery-mailer", [
"-l", user.login, "-l", user.login,
"-e", user.contact.email.not_nil!, "-e", user.contact.email.not_nil!,
@ -441,6 +453,7 @@ class AuthD::Service
"-u", mailer_activation_url, "-u", mailer_activation_url,
"-a", user.password_renew_key.not_nil! "-a", user.password_renew_key.not_nil!
]).success? ]).success?
return Response::Error.new "cannot contact the user for password recovery" return Response::Error.new "cannot contact the user for password recovery"
end end
end end
@ -683,7 +696,8 @@ begin
Baguette::Log.info "do not load a configuration file." Baguette::Log.info "do not load a configuration file."
Baguette::Configuration::Auth.new Baguette::Configuration::Auth.new
else else
Baguette::Configuration::Auth.get || Baguette::Configuration::Auth.new Baguette::Configuration::Auth.get(configuration_file) ||
Baguette::Configuration::Auth.new
end end
Baguette::Context.verbosity = configuration.verbosity Baguette::Context.verbosity = configuration.verbosity
@ -747,6 +761,7 @@ begin
authd.read_only_profile_keys = configuration.read_only_profile_keys authd.read_only_profile_keys = configuration.read_only_profile_keys
authd.print_timer = configuration.print_ipc_timer authd.print_timer = configuration.print_ipc_timer
authd.timer = configuration.ipc_timer authd.timer = configuration.ipc_timer
authd.print_password_recovery_parameters = configuration.print_password_recovery_parameters
end.run end.run
rescue e : OptionParser::Exception rescue e : OptionParser::Exception
Baguette::Log.error e.message Baguette::Log.error e.message