Skip to content

Instantly share code, notes, and snippets.

@jpfinlay
Created February 15, 2013 18:41
Show Gist options
  • Save jpfinlay/4962385 to your computer and use it in GitHub Desktop.
Save jpfinlay/4962385 to your computer and use it in GitHub Desktop.
class AuthorSessionsController < ApplicationController
def new
@author = Author.new
end
def create
@author = login(params[:username], params[:password])
if @author
redirect_back_or_to(articles_path, message: 'Logged in successfully.')
else
flash.now.alert = "Login failed."
render action: :new
end
end
def destroy
logout
redirect_to(:authors, message: 'Logged out!')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment