Created
March 28, 2019 12:23
-
-
Save MaryKuz/6b2f672be9d29210da58c7f808e8c668 to your computer and use it in GitHub Desktop.
Adding code to ApplicationController
This file contains 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
class ApplicationController < ActionController::Base | |
.... | |
before_action :authenticate | |
attr_reader :current_user | |
private | |
def authenticate | |
authenticate_or_request_with_http_token do |token, options| | |
@current_user = User.joins(:auth_token).find_by(auth_tokens: { value: token }) | |
end | |
end | |
.... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment