Skip to content

Instantly share code, notes, and snippets.

@igkuz
Created September 14, 2013 12:14
Show Gist options
  • Save igkuz/6561545 to your computer and use it in GitHub Desktop.
Save igkuz/6561545 to your computer and use it in GitHub Desktop.
class Web::SessionsController < Web::ApplicationController
def new
@user = User.new
end
def create
@user = User.find_by_email(params[:user][:email])
if @user && @user.authenticate(params[:user][:password])
sign_in(@user)
@user.admin? ? redirect_to(admin_root_path) : redirect_to(client_root_path)
else
@user = User.new(params[:user])
flash[:alert] = t("authenticate_error")
render :action => :new
end
end
def destroy
sign_out
redirect_to :root
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment