9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/standard_id/web/verify_email/start_controller.rb', line 9
def create
email = params[:email].to_s.strip.downcase
if email.blank?
flash[:alert] = "Please enter your email address"
render plain: "missing email", status: :unprocessable_content and return
end
challenge = StandardId::CodeChallenge.create!(
realm: "verification",
channel: "email",
target: email,
code: generate_otp_code,
expires_at: 10.minutes.from_now,
ip_address: StandardId::Utils::IpNormalizer.normalize(request.remote_ip),
user_agent: request.user_agent
)
StandardId.config.passwordless_email_sender&.call(email, challenge.code)
redirect_to standard_id_web.login_path, notice: "Verification code sent to your email", status: :see_other
end
|