This repository has been archived by the owner on Mar 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 253
login without email #183
Comments
You can modify the default behavior implementing within your entity model a class method from_token_request that takes the request in argument. class User < ActiveRecord::Base
def self.from_token_request(request)
username = request.params["auth"] && request.params["auth"]["username"]
self.find_by(username: username)
end
end More info: https://github.com/nsarno/knock#via-the-entity-model |
You might also need to override strong parameters:
class UserTokenController < Knock::AuthTokenController
private
def auth_params
params.require(:auth).permit(:username, :password)
end
end
class User < ActiveRecord::Base
def self.from_token_request(request)
username = request.params["auth"] && request.params["auth"]["username"]
self.find_by(username: username)
end
end |
I’m also using a username and no emails. What about making this configurable? |
Merged
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
My application logs in with username, how can I generate the token with username instead of email?
The text was updated successfully, but these errors were encountered: