Created
March 31, 2016 07:26
-
-
Save jetrubyshared/83e07526b410dd2a225a5ca7fe85b525 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
include JwtAuthentication | |
protect_from_forgery with: :exception | |
… | |
protected | |
… | |
def authenticate_customer_from_token! | |
if claims and customer = Customer.find_by(email: claims[0]['email']) | |
@current_customer = customer | |
else | |
invalid_authentication | |
end | |
end | |
def jwt_token(customer) | |
JsonWebToken.encode('customer' => customer.email) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment