MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / UserIDFromContext

Function UserIDFromContext

inventory/user.go:421–431  ·  view source on GitHub ↗

UserIDFromContext get user id from context.

(ctx context.Context)

Source from the content-addressed store, hash-verified

419
420// UserIDFromContext get user id from context.
421func UserIDFromContext(ctx context.Context) int {
422 uid, ok := ctx.Value(UserIDCtx{}).(int)
423 if !ok {
424 u := UserFromContext(ctx)
425 if u != nil {
426 uid = u.ID
427 }
428 }
429
430 return uid
431}
432
433func (c *userClient) AnonymousUser(ctx context.Context) (*ent.User, error) {
434 groupClient := NewGroupClient(c.client, "", nil)

Callers 4

CurrentUserFunction · 0.92
GetMethod · 0.92
DeleteMethod · 0.92
SendMethod · 0.92

Calls 2

UserFromContextFunction · 0.85
ValueMethod · 0.45

Tested by

no test coverage detected