knock icon indicating copy to clipboard operation
knock copied to clipboard

Everytime, every request I have: "User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]"

Open ghost opened this issue 7 years ago • 3 comments

I'm using:

class GoodsController < ApplicationController
  before_action :authenticate_user
  ....

so now I have everytime, every request in my log:

User Load (0.3ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]

Why? Everytime a query? Is token valid just with secret_key?

ghost avatar Mar 12 '17 23:03 ghost

I wonder the same. +1

enterteg avatar May 08 '17 14:05 enterteg

If I understand it correctly perhaps Knock calls the current_user method it defines to ensure the user still exists?

requnix avatar May 25 '17 09:05 requnix

I am facing the same issue. It executes following query for every request

SELECT "users".* FROM "users" WHERE "users"."email" = $1 LIMIT $2

We have separate front / back end application. We are integrating auth0 in our application.

For back authentication we are using knock gem.

I have added following code in my user.rb

def self.from_token_payload(payload)
   User.find_by_email(payload['email'])
   # or create new one
end

Every request comes to this method and each time its validating user.

Is there any configuration like it will call this method only once?

krunalsha avatar May 26 '17 12:05 krunalsha