Skip to content

Instantly share code, notes, and snippets.

@jetrubyshared
Created March 31, 2016 07:26
Show Gist options
  • Save jetrubyshared/83e07526b410dd2a225a5ca7fe85b525 to your computer and use it in GitHub Desktop.
Save jetrubyshared/83e07526b410dd2a225a5ca7fe85b525 to your computer and use it in GitHub Desktop.
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