Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to proceed when using multiple models for auth #29

Open
jvalenciag opened this issue Oct 23, 2018 · 4 comments
Open

How to proceed when using multiple models for auth #29

jvalenciag opened this issue Oct 23, 2018 · 4 comments

Comments

@jvalenciag
Copy link

I don't know how to make this gem work with multimple models for auth, how do I differentiate when generating the token?

@coalwater
Copy link

Could you explain your use case better ?

@phlegx
Copy link

phlegx commented Apr 16, 2019

I think @jvalenciag means multiple scopes like devise do.

@leehambley
Copy link

Same question here, we have either Driver or Client and I can find no way from the options hash that is yielded to the token_payload to the actual owner.

@linhdangduy
Copy link

I saw in the docs that token_payload could be configured.
So you can add the "role" field or any field into access token as your expect.

User model: { id: int, email: string,  role: ["driver"] }  

Doorkeeper::JWT.configure do
  ...
  token_payload do |opts|
    user = User.find(opts[:resource_owner_id])

    {
      ...
      user: {
        id: user.id,
        email: user.email,
        role: user.role
      }
    }
  end
  ...
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants