Last active
July 3, 2018 20:36
-
-
Save afcapel/c534b63975d26bce9a072344b64a86b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/concerns/authentication.rb | |
# (Authorisation is different than Authentication and so it is handled in a different concern) | |
module Authentication | |
extend ActiveSupport::Concern | |
included do | |
before_action :authenticate | |
helper_method :logged_in? | |
end | |
private | |
def logged_in? | |
Current.person.present? | |
end | |
def authenticate | |
if authenticated_user = Person.find_by(id: session[:person_id]) | |
Current.person = authenticated_user | |
end | |
end | |
def sign_in(person) | |
session[:person_id] = person.id | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment