Class: Postnhost::SessionsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/postnhost/sessions_controller.rb', line 8

def create
  user = Postnhost::User.find_by(email: session_params[:email].to_s.downcase.strip)

  if user&.authenticate(session_params[:password].to_s)
    (user)
    redirect_to articles_path
  else
    flash.now[:alert] = "Invalid email or password."
    render :new, status: :unprocessable_content
  end
end

#destroyObject



20
21
22
23
# File 'app/controllers/postnhost/sessions_controller.rb', line 20

def destroy
  sign_out
  redirect_to root_path
end

#newObject



6
# File 'app/controllers/postnhost/sessions_controller.rb', line 6

def new; end