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

Method GetProfile

internal/api/v1/session/session.go:404–436  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

402}
403
404func (h *Handler) GetProfile() iris.Handler {
405 return func(ctx *context.Context) {
406 session := server.SessionMgr.Start(ctx)
407 loginUser := session.Get("profile")
408 if loginUser == nil {
409 ctx.StatusCode(iris.StatusUnauthorized)
410 ctx.Values().Set("message", "no login user")
411 return
412 }
413 p, ok := loginUser.(UserProfile)
414 if !ok {
415 ctx.StatusCode(iris.StatusInternalServerError)
416 ctx.Values().Set("message", "can not parse to session user")
417 return
418 }
419
420 user, err := h.userService.GetByNameOrEmail(p.Name, common.DBOptions{})
421 if err != nil {
422 ctx.StatusCode(iris.StatusInternalServerError)
423 ctx.Values().Set("message", err.Error())
424 return
425 }
426 p, err = h.buildUserProfile(user, p.Mfa.Approved)
427 if err != nil {
428 ctx.StatusCode(iris.StatusInternalServerError)
429 ctx.Values().Set("message", err.Error())
430 return
431 }
432 session.Set("profile", p)
433 ctx.StatusCode(iris.StatusOK)
434 ctx.Values().Set("data", p)
435 }
436}
437
438func (h *Handler) ListUserNamespace() iris.Handler {
439 return func(ctx *context.Context) {

Callers 1

InstallFunction · 0.95

Calls 5

buildUserProfileMethod · 0.95
ErrorMethod · 0.80
GetMethod · 0.65
GetByNameOrEmailMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected