This repository has been archived on 2020-05-27. You can view files and clone it, but cannot push or open issues/pull-requests.
tuxbliki/app/controllers/sessions.rb

29 lines
519 B
Ruby

class Sessions < Application
def new
only_provides :html
render
end
def create
author = Author.authenticate(params[:username], params[:password])
if author
session[:author_id] = author.id
flash[:notice] = "Welcome back #{author.name}"
redirect '/'
else
flash[:error] = 'Login failed.'
render :new
end
end
def update
redirect '/'
end
def delete
session[:author_id] = nil
flash[:notice] = "You have logged out"
redirect '/'
end
end