MCPcopy Create free account
hub / github.com/gogs/gogs / prepareUserInfo

Function prepareUserInfo

internal/route/admin/users.go:116–142  ·  view source on GitHub ↗
(c *context.Context)

Source from the content-addressed store, hash-verified

114}
115
116func prepareUserInfo(c *context.Context) *database.User {
117 u, err := database.Handle.Users().GetByID(c.Req.Context(), c.ParamsInt64(":userid"))
118 if err != nil {
119 c.Error(err, "get user by ID")
120 return nil
121 }
122 c.Data["User"] = u
123
124 if u.LoginSource > 0 {
125 c.Data["LoginSource"], err = database.Handle.LoginSources().GetByID(c.Req.Context(), u.LoginSource)
126 if err != nil {
127 c.Error(err, "get login source by ID")
128 return nil
129 }
130 } else {
131 c.Data["LoginSource"] = &database.LoginSource{}
132 }
133
134 sources, err := database.Handle.LoginSources().List(c.Req.Context(), database.ListLoginSourceOptions{})
135 if err != nil {
136 c.Error(err, "list login sources")
137 return nil
138 }
139 c.Data["Sources"] = sources
140
141 return u
142}
143
144func EditUser(c *context.Context) {
145 c.Data["Title"] = c.Tr("admin.users.edit_account")

Callers 2

EditUserFunction · 0.85
EditUserPostFunction · 0.85

Calls 5

UsersMethod · 0.80
LoginSourcesMethod · 0.80
GetByIDMethod · 0.65
ListMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected