Class: Admin::UserSessionsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Trek::Authentication
Defined in:
lib/generators/trek/templates/controllers/admin/user_sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
# File 'lib/generators/trek/templates/controllers/admin/user_sessions_controller.rb', line 21

def create
  if user = User.privileged.authenticate_by(session_params)
    start_new_session_for user
    redirect_to after_authentication_url, notice: t(".success")
  else
    redirect_to new_admin_user_session_path, alert: t(".failure")
  end
end

#destroyObject



30
31
32
33
# File 'lib/generators/trek/templates/controllers/admin/user_sessions_controller.rb', line 30

def destroy
  terminate_session
  redirect_to new_admin_user_session_path, notice: t(".success"), status: :see_other
end

#newObject



15
16
17
18
19
# File 'lib/generators/trek/templates/controllers/admin/user_sessions_controller.rb', line 15

def new
  return redirect_to after_authentication_url if authenticated?

  @email = params[:email].presence
end