summaryrefslogtreecommitdiffstats
path: root/routers/admin/users.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-12-25 09:59:32 +0000
committerGitHub <noreply@github.com>2020-12-25 11:59:32 +0200
commita19447aed128ecadfcd938d6a80cd4951af1f4ce (patch)
tree6312bf946d601aab29731645a4777feeaea66036 /routers/admin/users.go
parent04ae0f2f3f4556c6d0b4adc5f2cffd0cc7d25151 (diff)
downloadgitea-a19447aed128ecadfcd938d6a80cd4951af1f4ce.tar.gz
gitea-a19447aed128ecadfcd938d6a80cd4951af1f4ce.zip
migrate from com.* to alternatives (#14103)
* remove github.com/unknwon/com from models * dont use "com.ToStr()" * replace "com.ToStr" with "fmt.Sprint" where its easy to do * more refactor * fix test * just "proxy" Copy func for now * as per @lunny
Diffstat (limited to 'routers/admin/users.go')
-rw-r--r--routers/admin/users.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/routers/admin/users.go b/routers/admin/users.go
index 06c391b8e0..2ea496624b 100644
--- a/routers/admin/users.go
+++ b/routers/admin/users.go
@@ -6,6 +6,8 @@
package admin
import (
+ "fmt"
+ "strconv"
"strings"
"code.gitea.io/gitea/models"
@@ -17,8 +19,6 @@ import (
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/routers"
"code.gitea.io/gitea/services/mailer"
-
- "github.com/unknwon/com"
)
const (
@@ -92,8 +92,9 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
if len(form.LoginType) > 0 {
fields := strings.Split(form.LoginType, "-")
if len(fields) == 2 {
- u.LoginType = models.LoginType(com.StrTo(fields[0]).MustInt())
- u.LoginSource = com.StrTo(fields[1]).MustInt64()
+ lType, _ := strconv.ParseInt(fields[0], 10, 0)
+ u.LoginType = models.LoginType(lType)
+ u.LoginSource, _ = strconv.ParseInt(fields[1], 10, 64)
u.LoginName = form.LoginName
}
}
@@ -154,7 +155,7 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
}
ctx.Flash.Success(ctx.Tr("admin.users.new_success", u.Name))
- ctx.Redirect(setting.AppSubURL + "/admin/users/" + com.ToStr(u.ID))
+ ctx.Redirect(setting.AppSubURL + "/admin/users/" + fmt.Sprint(u.ID))
}
func prepareUserInfo(ctx *context.Context) *models.User {
@@ -220,12 +221,12 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
fields := strings.Split(form.LoginType, "-")
if len(fields) == 2 {
- loginType := models.LoginType(com.StrTo(fields[0]).MustInt())
- loginSource := com.StrTo(fields[1]).MustInt64()
+ loginType, _ := strconv.ParseInt(fields[0], 10, 0)
+ loginSource, _ := strconv.ParseInt(fields[1], 10, 64)
if u.LoginSource != loginSource {
u.LoginSource = loginSource
- u.LoginType = loginType
+ u.LoginType = models.LoginType(loginType)
}
}