MCPcopy Create free account
hub / github.com/golang/appengine / Current

Function Current

user/user_vm.go:18–32  ·  view source on GitHub ↗

Current returns the currently logged-in user, or nil if the user is not signed in.

(c context.Context)

Source from the content-addressed store, hash-verified

16// Current returns the currently logged-in user,
17// or nil if the user is not signed in.
18func Current(c context.Context) *User {
19 h := internal.IncomingHeaders(c)
20 u := &User{
21 Email: h.Get("X-AppEngine-User-Email"),
22 AuthDomain: h.Get("X-AppEngine-Auth-Domain"),
23 ID: h.Get("X-AppEngine-User-Id"),
24 Admin: h.Get("X-AppEngine-User-Is-Admin") == "1",
25 FederatedIdentity: h.Get("X-AppEngine-Federated-Identity"),
26 FederatedProvider: h.Get("X-AppEngine-Federated-Provider"),
27 }
28 if u.Email == "" && u.FederatedIdentity == "" {
29 return nil
30 }
31 return u
32}
33
34// IsAdmin returns true if the current user is signed in and
35// is currently registered as an administrator of the application.

Callers 1

TestBasicUserAPIFunction · 0.70

Calls 2

IncomingHeadersFunction · 0.92
GetMethod · 0.45

Tested by 1

TestBasicUserAPIFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…