rename Context to ReqContext

This commit is contained in:
Dan Cech
2018-03-07 11:54:50 -05:00
parent 338655dd37
commit c0ecdee375
63 changed files with 241 additions and 241 deletions
+16 -16
View File
@@ -9,12 +9,12 @@ import (
)
// GET /api/user (current authenticated user)
func GetSignedInUser(c *m.Context) Response {
func GetSignedInUser(c *m.ReqContext) Response {
return getUserUserProfile(c.UserId)
}
// GET /api/users/:id
func GetUserById(c *m.Context) Response {
func GetUserById(c *m.ReqContext) Response {
return getUserUserProfile(c.ParamsInt64(":id"))
}
@@ -32,7 +32,7 @@ func getUserUserProfile(userId int64) Response {
}
// GET /api/users/lookup
func GetUserByLoginOrEmail(c *m.Context) Response {
func GetUserByLoginOrEmail(c *m.ReqContext) Response {
query := m.GetUserByLoginQuery{LoginOrEmail: c.Query("loginOrEmail")}
if err := bus.Dispatch(&query); err != nil {
if err == m.ErrUserNotFound {
@@ -54,7 +54,7 @@ func GetUserByLoginOrEmail(c *m.Context) Response {
}
// POST /api/user
func UpdateSignedInUser(c *m.Context, cmd m.UpdateUserCommand) Response {
func UpdateSignedInUser(c *m.ReqContext, cmd m.UpdateUserCommand) Response {
if setting.AuthProxyEnabled {
if setting.AuthProxyHeaderProperty == "email" && cmd.Email != c.Email {
return ApiError(400, "Not allowed to change email when auth proxy is using email property", nil)
@@ -68,13 +68,13 @@ func UpdateSignedInUser(c *m.Context, cmd m.UpdateUserCommand) Response {
}
// POST /api/users/:id
func UpdateUser(c *m.Context, cmd m.UpdateUserCommand) Response {
func UpdateUser(c *m.ReqContext, cmd m.UpdateUserCommand) Response {
cmd.UserId = c.ParamsInt64(":id")
return handleUpdateUser(cmd)
}
//POST /api/users/:id/using/:orgId
func UpdateUserActiveOrg(c *m.Context) Response {
func UpdateUserActiveOrg(c *m.ReqContext) Response {
userId := c.ParamsInt64(":id")
orgId := c.ParamsInt64(":orgId")
@@ -107,12 +107,12 @@ func handleUpdateUser(cmd m.UpdateUserCommand) Response {
}
// GET /api/user/orgs
func GetSignedInUserOrgList(c *m.Context) Response {
func GetSignedInUserOrgList(c *m.ReqContext) Response {
return getUserOrgList(c.UserId)
}
// GET /api/user/:id/orgs
func GetUserOrgList(c *m.Context) Response {
func GetUserOrgList(c *m.ReqContext) Response {
return getUserOrgList(c.ParamsInt64(":id"))
}
@@ -145,7 +145,7 @@ func validateUsingOrg(userId int64, orgId int64) bool {
}
// POST /api/user/using/:id
func UserSetUsingOrg(c *m.Context) Response {
func UserSetUsingOrg(c *m.ReqContext) Response {
orgId := c.ParamsInt64(":id")
if !validateUsingOrg(c.UserId, orgId) {
@@ -162,7 +162,7 @@ func UserSetUsingOrg(c *m.Context) Response {
}
// GET /profile/switch-org/:id
func ChangeActiveOrgAndRedirectToHome(c *m.Context) {
func ChangeActiveOrgAndRedirectToHome(c *m.ReqContext) {
orgId := c.ParamsInt64(":id")
if !validateUsingOrg(c.UserId, orgId) {
@@ -178,7 +178,7 @@ func ChangeActiveOrgAndRedirectToHome(c *m.Context) {
c.Redirect(setting.AppSubUrl + "/")
}
func ChangeUserPassword(c *m.Context, cmd m.ChangeUserPasswordCommand) Response {
func ChangeUserPassword(c *m.ReqContext, cmd m.ChangeUserPasswordCommand) Response {
if setting.LdapEnabled || setting.AuthProxyEnabled {
return ApiError(400, "Not allowed to change password when LDAP or Auth Proxy is enabled", nil)
}
@@ -210,7 +210,7 @@ func ChangeUserPassword(c *m.Context, cmd m.ChangeUserPasswordCommand) Response
}
// GET /api/users
func SearchUsers(c *m.Context) Response {
func SearchUsers(c *m.ReqContext) Response {
query, err := searchUser(c)
if err != nil {
return ApiError(500, "Failed to fetch users", err)
@@ -220,7 +220,7 @@ func SearchUsers(c *m.Context) Response {
}
// GET /api/users/search
func SearchUsersWithPaging(c *m.Context) Response {
func SearchUsersWithPaging(c *m.ReqContext) Response {
query, err := searchUser(c)
if err != nil {
return ApiError(500, "Failed to fetch users", err)
@@ -229,7 +229,7 @@ func SearchUsersWithPaging(c *m.Context) Response {
return Json(200, query.Result)
}
func searchUser(c *m.Context) (*m.SearchUsersQuery, error) {
func searchUser(c *m.ReqContext) (*m.SearchUsersQuery, error) {
perPage := c.QueryInt("perpage")
if perPage <= 0 {
perPage = 1000
@@ -257,7 +257,7 @@ func searchUser(c *m.Context) (*m.SearchUsersQuery, error) {
return query, nil
}
func SetHelpFlag(c *m.Context) Response {
func SetHelpFlag(c *m.ReqContext) Response {
flag := c.ParamsInt64(":id")
bitmask := &c.HelpFlags1
@@ -275,7 +275,7 @@ func SetHelpFlag(c *m.Context) Response {
return Json(200, &util.DynMap{"message": "Help flag set", "helpFlags1": cmd.HelpFlags1})
}
func ClearHelpFlags(c *m.Context) Response {
func ClearHelpFlags(c *m.ReqContext) Response {
cmd := m.SetUserHelpFlagCommand{
UserId: c.UserId,
HelpFlags1: m.HelpFlags1(0),