Knock: How to customize user_token response

Created on 14 Jan 2017  路  2Comments  路  Source: nsarno/knock

Hy,
I'm using your knock gem in a rails 5 api. My question is, if or how I can modify the method user_token to e.g. also return some data of the current or authenticated user? (in addition to the jwt)
I guess i could create my own auth_token_controller.rb but if there's a simpler / easier way, I would appreciate it.
Thx

Most helpful comment

alright .. I thought this gem is going to be maintained? 馃馃様

however, i solved my own problem by overriding the class method by creating a ruby file in the initializers including this code:

Knock::AuthTokenController.class_eval do

  def create
    render json: {
        jwt: auth_token.token,
        myparam: my_value
      }, status: :created
  end

end

All 2 comments

alright .. I thought this gem is going to be maintained? 馃馃様

however, i solved my own problem by overriding the class method by creating a ruby file in the initializers including this code:

Knock::AuthTokenController.class_eval do

  def create
    render json: {
        jwt: auth_token.token,
        myparam: my_value
      }, status: :created
  end

end

This should be added in my opinion

117 seems to describe a solution tho

Was this page helpful?
0 / 5 - 0 ratings