Class: StandardId::Web::VerifyEmail::StartController

Inherits:
BaseController show all
Defined in:
app/controllers/standard_id/web/verify_email/start_controller.rb

Instance Method Summary collapse

Methods included from ControllerPolicy

all_controllers, authenticated_controllers, public_controllers, register, registry_snapshot, reset_registry!

Instance Method Details

#createObject



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., notice: "Verification code sent to your email", status: :see_other
end

#showObject



5
6
7
# File 'app/controllers/standard_id/web/verify_email/start_controller.rb', line 5

def show
  render plain: "verify email start", status: :ok
end