MCPcopy Index your code
hub / github.com/1Panel-dev/KubePi / buildUserProfile

Method buildUserProfile

internal/api/v1/session/session.go:78–97  ·  view source on GitHub ↗
(u *v1User.User, mfaApproved bool)

Source from the content-addressed store, hash-verified

76}
77
78func (h *Handler) buildUserProfile(u *v1User.User, mfaApproved bool) (UserProfile, error) {
79 permissions, err := h.AggregateResourcePermissions(u.Name)
80 if err != nil {
81 return UserProfile{}, err
82 }
83 return UserProfile{
84 Name: u.Name,
85 NickName: u.NickName,
86 Email: u.Email,
87 Language: u.Language,
88 ResourcePermissions: permissions,
89 IsAdministrator: u.IsAdmin,
90 Mfa: Mfa{
91 Enable: u.Mfa.Enable,
92 Configured: strings.TrimSpace(u.Mfa.Secret) != "",
93 Approved: mfaApproved,
94 },
95 ForceChangePassword: isDefaultAdminPassword(u),
96 }, nil
97}
98
99func isDefaultAdminPassword(u *v1User.User) bool {
100 if u == nil || u.Name != defaultAdminName || !u.IsAdmin {

Callers 2

LoginMethod · 0.95
GetProfileMethod · 0.95

Calls 2

isDefaultAdminPasswordFunction · 0.85

Tested by

no test coverage detected