Class: StandardId::Web::VerifyPhone::StartController
- Inherits:
-
BaseController
show all
- Defined in:
- app/controllers/standard_id/web/verify_phone/start_controller.rb
Instance Method Summary
collapse
all_controllers, authenticated_controllers, public_controllers, register, registry_snapshot, reset_registry!
Instance Method Details
#create ⇒ Object
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_phone/start_controller.rb', line 9
def create
phone = params[:phone_number].to_s.strip
if phone.blank? || !(phone.match?(/\A\+?[1-9]\d{1,14}\z/))
flash[:alert] = "Please enter a valid phone number"
render plain: "invalid phone", status: :unprocessable_content and return
end
challenge = StandardId::CodeChallenge.create!(
realm: "verification",
channel: "sms",
target: phone,
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_sms_sender&.call(phone, challenge.code)
redirect_to standard_id_web.login_path, notice: "Verification code sent via SMS", status: :see_other
end
|
#show ⇒ Object
5
6
7
|
# File 'app/controllers/standard_id/web/verify_phone/start_controller.rb', line 5
def show
render plain: "verify phone start", status: :ok
end
|