Class: SessionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/sessions_controller.rb

Instance Attribute Summary

Attributes included from Authentication

#current_user

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
# File 'app/controllers/sessions_controller.rb', line 7

def create
  if @user.authenticate_by_phone(create_params.dig(:otp))
    start_new_session_for @user
    token = JwtAuthenticate.encode(user_id: @user.id)
    ok(token: token)
  else
    bad_request(Otp::Errors::InvalidOtpError.new.message)
  end
end

#destroyObject



17
18
19
20
21
# File 'app/controllers/sessions_controller.rb', line 17

def destroy
  terminate_session

  ok
end