From bc05ddc0ebd6fdc826ef2beec99304bac60ddd8a Mon Sep 17 00:00:00 2001 From: Andrew Bezold Date: Sun, 24 Jan 2021 10:23:05 -0500 Subject: Redirect on changed user and org name (#11649) * Add redirect for user * Add redirect for orgs * Add user redirect test * Appease linter * Add comment to DeleteUserRedirect function * Fix locale changes * Fix GetUserByParams * Fix orgAssignment * Remove debug logging * Add redirect prompt * Dont Export DeleteUserRedirect & only use it within a session * Unexport newUserRedirect * cleanup * Fix & Dedub API code * Format Template * Add Migration & rm dublicat * Refactor: unexport newRepoRedirect() & rm dedub del exec * if this fails we'll need to re-rename the user directory Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath Co-authored-by: Lunny Xiao --- routers/api/v1/user/user.go | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'routers/api/v1/user/user.go') diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index b860219e62..ecc149fe52 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -107,13 +107,8 @@ func GetInfo(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - u, err := models.GetUserByName(ctx.Params(":username")) - if err != nil { - if models.IsErrUserNotExist(err) { - ctx.NotFound() - } else { - ctx.Error(http.StatusInternalServerError, "GetUserByName", err) - } + u := GetUserByParams(ctx) + if ctx.Written() { return } @@ -153,14 +148,8 @@ func GetUserHeatmapData(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - // Get the user to throw an error if it does not exist - user, err := models.GetUserByName(ctx.Params(":username")) - if err != nil { - if models.IsErrUserNotExist(err) { - ctx.Status(http.StatusNotFound) - } else { - ctx.Error(http.StatusInternalServerError, "GetUserByName", err) - } + user := GetUserByParams(ctx) + if ctx.Written() { return } -- cgit v1.2.3