Class: SmsAuths::SignInsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/action_auth/sms_auths/sign_ins_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/action_auth/sms_auths/sign_ins_controller.rb', line 7

def create
  user = ActionAuth::User.find_by(
    phone_number: cookies.signed[:sms_auth_phone_number],
    sms_code: params[:sms_code],
    sms_code_sent_at: 5.minutes.ago..Time.current
  )
  if user
    @session = user.sessions.create
    cookies.signed.permanent[:session_token] = { value: @session.id, httponly: true }
    user.update(
      verified: true,
      sms_code: nil,
      sms_code_sent_at: nil
    )
    redirect_to main_app.root_path, notice: "Signed In"
  else
    redirect_to , alert: "Authentication failed, please try again."
  end
end

#showObject



3
4
5
# File 'app/controllers/action_auth/sms_auths/sign_ins_controller.rb', line 3

def show
  @user = ActionAuth::User.find_by(phone_number: params[:phone_number])
end