You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both make a query. LoadCurrentUser calls CurrentUser under the hood anyway. The difference is the parameters. One takes a **http.Request that's a pointer to a pointer meaning that the original pointer that you're passing in can be modified. This allows it to replace the http.Request with one that has the user loaded into it's request.Context. Which isn't possible with CurrentUser.
It depends on your needs which one you're going to call. The advantage being that LoadCurrentUser caches it in the request. But if you're not a middleware you're the endpoint handler for example then there's no point to calling LoadCurrentUser, just use CurrentUser.
frederikhors
changed the title
ab.CurrentUser() vs Ab.LoadCurrentUser(). Save DB queries. What is the right one to use?
ab.CurrentUser() vs Ab.LoadCurrentUser(). What is the right one to use?
Jan 12, 2019
frederikhors
changed the title
ab.CurrentUser() vs Ab.LoadCurrentUser(). What is the right one to use?
CurrentUser() vs LoadCurrentUser(). What is the right one to use?
Jan 12, 2019
Issue opened for the creation of a wiki page that summarizes the doubts and problems for newbies (#210).
I'm using https://github.com/justinas/nosurf for CSRF (like in
authboss-sample
after all).I'm using the below code to create the "
X-CSRF-Token
" to send to the javascript app.And this is the
main()
:As you can read I'm using
to query for the
User
and notas you suggest in Readme because
ab.CurrentUser(r)
is making a query, the other one not.My newbie question: WHY?
What is the right thing to do?
The text was updated successfully, but these errors were encountered: