Skip to content

Instantly share code, notes, and snippets.

@kenyonj
Created May 28, 2014 20:31
Show Gist options
  • Save kenyonj/141848bfbba553a1938c to your computer and use it in GitHub Desktop.
Save kenyonj/141848bfbba553a1938c to your computer and use it in GitHub Desktop.
class SessionsController < ApplicationController
skip_before_action :require_login, only: [:new, :create]
def new
end
def create
@user = authenticate_session(session_params, email_or_username: [:email, :username])
if sign_in(@user)
redirect_to @user
else
render :new
end
end
def destroy
sign_out
redirect_to root_path
end
private
def session_params
params.require(:session).permit(:email_or_username, :password)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment