Run the activation-mailer.

ipc07
Philippe PITTOLI 2020-01-23 15:45:05 +01:00
parent 8ddf5cf316
commit e789a16ac6
1 changed files with 16 additions and 2 deletions

View File

@ -82,14 +82,24 @@ class AuthD::Service
user.contact.email = request.email user.contact.email = request.email
user.contact.phone = request.phone unless request.phone.nil? user.contact.phone = request.phone unless request.phone.nil?
pp! user
request.profile.try do |profile| request.profile.try do |profile|
user.profile = profile user.profile = profile
end end
@users << user @users << user
# Once the user is created and stored, we try to contact him
# TODO: send a mail
unless Process.run("activation-mailer", [
"-l", user.login,
"-e", user.contact.email.not_nil!,
"-t", "Activation email",
"-f", "karchnu@localhost",
"-a", user.contact.activation_key.not_nil!
]).success?
return Response::Error.new "cannot contact the user"
end
Response::UserAdded.new user.to_public Response::UserAdded.new user.to_public
when Request::ValidateUser when Request::ValidateUser
if request.shared_key != @jwt_key if request.shared_key != @jwt_key
@ -102,6 +112,10 @@ class AuthD::Service
return Response::Error.new "user not found" return Response::Error.new "user not found"
end end
if user.contact.activation_key.nil?
return Response::Error.new "user already validated"
end
# remove the user contact activation key: the email is validated # remove the user contact activation key: the email is validated
if user.contact.activation_key == request.activation_key if user.contact.activation_key == request.activation_key
user.contact.activation_key = nil user.contact.activation_key = nil