Class: ActionAuth::SessionsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/action_auth/sessions_controller.rb', line 14

def create
  if user = User.authenticate_by(email: params[:email], password: params[:password])
    if user.second_factor_enabled?
      session[:webauthn_user_id] = user.id
      redirect_to new_webauthn_credential_authentications_path
    else
      return if check_if_email_is_verified(user)
      @session = user.sessions.create
      cookies.signed.permanent[:session_token] = { value: @session.id, httponly: true }
      redirect_to main_app.root_path, notice: "Signed in successfully"
    end
  else
    redirect_to (email_hint: params[:email]), alert: "That email or password is incorrect"
  end
end

#destroyObject



30
31
32
33
34
# File 'app/controllers/action_auth/sessions_controller.rb', line 30

def destroy
  session = Current.user.sessions.find(params[:id])
  session.destroy
  redirect_to main_app.root_path, notice: "That session has been logged out"
end

#indexObject



6
7
8
9
# File 'app/controllers/action_auth/sessions_controller.rb', line 6

def index
  @action_auth_wide = true
  @sessions = Current.user.sessions.order(created_at: :desc)
end

#newObject



11
12
# File 'app/controllers/action_auth/sessions_controller.rb', line 11

def new
end