Closed frederikhors closed 5 years ago
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
.
Issue opened for the creation of a wiki page that summarizes the doubts and problems for newbies (https://github.com/volatiletech/authboss/issues/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?