Class: Nquery::SessionsController
Constant Summary
AuthorizesCollection::COLLECTION_REQUIREMENTS
Instance Method Summary
collapse
#breadcrumbs, #set_breadcrumbs
Instance Method Details
#create ⇒ Object
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
|
#destroy ⇒ Object
23
24
25
26
|
# File 'app/controllers/nquery/sessions_controller.rb', line 23
def destroy
session.delete(:nquery_user_id)
redirect_to login_path, notice: "Signed out."
end
|
#new ⇒ Object
8
9
10
|
# File 'app/controllers/nquery/sessions_controller.rb', line 8
def new
redirect_to root_path if current_nquery_user
end
|