MCPcopy Index your code
hub / github.com/rilldata/rill / GetCurrentUser

Method GetCurrentUser

admin/server/users.go:105–129  ·  view source on GitHub ↗
(ctx context.Context, req *adminv1.GetCurrentUserRequest)

Source from the content-addressed store, hash-verified

103}
104
105func (s *Server) GetCurrentUser(ctx context.Context, req *adminv1.GetCurrentUserRequest) (*adminv1.GetCurrentUserResponse, error) {
106 // Return an empty result if not authenticated.
107 claims := auth.GetClaims(ctx)
108 if claims.OwnerType() == auth.OwnerTypeAnon {
109 return &adminv1.GetCurrentUserResponse{}, nil
110 }
111
112 // Error if authenticated as anything other than a user
113 if claims.OwnerType() != auth.OwnerTypeUser {
114 return nil, status.Error(codes.Unauthenticated, "not authenticated as a user")
115 }
116
117 // Owner is a user
118 u, err := s.admin.DB.FindUser(ctx, claims.OwnerID())
119 if err != nil {
120 return nil, err
121 }
122
123 return &adminv1.GetCurrentUserResponse{
124 User: s.userToPB(u, true),
125 Preferences: &adminv1.UserPreferences{
126 TimeZone: &u.PreferenceTimeZone,
127 },
128 }, nil
129}
130
131func (s *Server) UpdateUserPreferences(ctx context.Context, req *adminv1.UpdateUserPreferencesRequest) (*adminv1.UpdateUserPreferencesResponse, error) {
132 claims := auth.GetClaims(ctx)

Callers

nothing calls this directly

Calls 6

userToPBMethod · 0.95
GetClaimsFunction · 0.92
OwnerTypeMethod · 0.65
FindUserMethod · 0.65
OwnerIDMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected