Class: Nquery::SessionsController

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

Constant Summary

Constants included from AuthorizesCollection

AuthorizesCollection::COLLECTION_REQUIREMENTS

Instance Method Summary collapse

Methods included from Breadcrumbs

#breadcrumbs, #set_breadcrumbs

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/nquery/sessions_controller.rb', line 12

def create
  user = User.active.find_by(email: params[:email]&.downcase)
  if user&.authenticate(params[:password])
    session[:nquery_user_id] = user.id
    redirect_to root_path, notice: "Signed in successfully."
  else
    flash.now[:alert] = "Invalid email or password."
    render :new, status: :unprocessable_content
  end
end

#destroyObject



23
24
25
26
# File 'app/controllers/nquery/sessions_controller.rb', line 23

def destroy
  session.delete(:nquery_user_id)
  redirect_to , notice: "Signed out."
end

#newObject



8
9
10
# File 'app/controllers/nquery/sessions_controller.rb', line 8

def new
  redirect_to root_path if current_nquery_user
end