8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/registrations_controller.rb', line 8
def create
unless Studio.auth_method?(:password)
email = (params.dig(:user, :email) || params[:email]).to_s.strip.downcase
if email.match?(URI::MailTo::EMAIL_REGEXP)
token = MagicLink.generate(email: email)
UserMailer.magic_link(email, token).deliver_later
end
return redirect_to login_path, notice: "Check your inbox — we just emailed you a sign-in link."
end
@user = User.new(user_params)
Studio.configure_new_user.call(@user)
rescue_and_log(target: @user) do
@user.save!
set_app_session(@user)
redirect_to root_path, notice: Studio.welcome_message.call(@user)
end
rescue StandardError => e
render :new, status: :unprocessable_entity
end
|