MCPcopy Index your code
hub / github.com/git-bug/git-bug / UserFromCtx

Function UserFromCtx

api/auth/context.go:22–28  ·  view source on GitHub ↗

UserFromCtx retrieves an IdentityCache from the context. If there is no identity in the context, ErrNotAuthenticated is returned. If an error occurs while resolving the identity (e.g. I/O error), then it will be returned.

(ctx context.Context, r *cache.RepoCache)

Source from the content-addressed store, hash-verified

20// If there is no identity in the context, ErrNotAuthenticated is returned.
21// If an error occurs while resolving the identity (e.g. I/O error), then it will be returned.
22func UserFromCtx(ctx context.Context, r *cache.RepoCache) (*cache.IdentityCache, error) {
23 id, ok := ctx.Value(identityCtxKey).(entity.Id)
24 if !ok {
25 return nil, ErrNotAuthenticated
26 }
27 return r.Identities().Resolve(id)
28}

Callers 11

ServeHTTPMethod · 0.92
UserIdentityMethod · 0.92
BugCreateMethod · 0.92
BugAddCommentMethod · 0.92
BugAddCommentAndCloseMethod · 0.92
BugEditCommentMethod · 0.92
BugChangeLabelsMethod · 0.92
BugStatusOpenMethod · 0.92
BugStatusCloseMethod · 0.92
BugSetTitleMethod · 0.92

Calls 2

IdentitiesMethod · 0.80
ResolveMethod · 0.65

Tested by

no test coverage detected