summaryrefslogtreecommitdiffstats
path: root/routers/admin
diff options
context:
space:
mode:
Diffstat (limited to 'routers/admin')
-rw-r--r--routers/admin/admin.go11
-rw-r--r--routers/admin/auth.go12
-rw-r--r--routers/admin/user.go29
3 files changed, 26 insertions, 26 deletions
diff --git a/routers/admin/admin.go b/routers/admin/admin.go
index eb4123435a..efdc803b95 100644
--- a/routers/admin/admin.go
+++ b/routers/admin/admin.go
@@ -10,7 +10,8 @@ import (
"strings"
"time"
- "github.com/go-martini/martini"
+ "github.com/Unknwon/com"
+ "github.com/Unknwon/macaron"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
@@ -126,7 +127,7 @@ func Dashboard(ctx *middleware.Context) {
ctx.Data["PageIsDashboard"] = true
// Run operation.
- op, _ := base.StrTo(ctx.Query("op")).Int()
+ op, _ := com.StrTo(ctx.Query("op")).Int()
if op > 0 {
var err error
var success string
@@ -159,7 +160,7 @@ func Users(ctx *middleware.Context) {
ctx.Data["Title"] = "User Management"
ctx.Data["PageIsUsers"] = true
- p := base.StrTo(ctx.Query("p")).MustInt()
+ p := com.StrTo(ctx.Query("p")).MustInt()
if p < 1 {
p = 1
}
@@ -188,7 +189,7 @@ func Repositories(ctx *middleware.Context) {
ctx.Data["Title"] = "Repository Management"
ctx.Data["PageIsRepos"] = true
- p := base.StrTo(ctx.Query("p")).MustInt()
+ p := com.StrTo(ctx.Query("p")).MustInt()
if p < 1 {
p = 1
}
@@ -235,7 +236,7 @@ func Config(ctx *middleware.Context) {
ctx.Data["OfflineMode"] = setting.OfflineMode
ctx.Data["DisableRouterLog"] = setting.DisableRouterLog
ctx.Data["RunUser"] = setting.RunUser
- ctx.Data["RunMode"] = strings.Title(martini.Env)
+ ctx.Data["RunMode"] = strings.Title(macaron.Env)
ctx.Data["RepoRootPath"] = setting.RepoRootPath
ctx.Data["StaticRootPath"] = setting.StaticRootPath
ctx.Data["LogRootPath"] = setting.LogRootPath
diff --git a/routers/admin/auth.go b/routers/admin/auth.go
index ff6c0325b6..44af962751 100644
--- a/routers/admin/auth.go
+++ b/routers/admin/auth.go
@@ -7,7 +7,7 @@ package admin
import (
"strings"
- "github.com/go-martini/martini"
+ "github.com/Unknwon/com"
"github.com/go-xorm/core"
"github.com/gogits/gogs/models"
@@ -89,13 +89,13 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
ctx.Redirect("/admin/auths")
}
-func EditAuthSource(ctx *middleware.Context, params martini.Params) {
+func EditAuthSource(ctx *middleware.Context) {
ctx.Data["Title"] = "Edit Authentication"
ctx.Data["PageIsAuths"] = true
ctx.Data["LoginTypes"] = models.LoginTypes
ctx.Data["SMTPAuths"] = models.SMTPAuths
- id, err := base.StrTo(params["authid"]).Int64()
+ id, err := com.StrTo(ctx.Params(":authid")).Int64()
if err != nil {
ctx.Handle(404, "admin.auths.EditAuthSource", err)
return
@@ -168,11 +168,11 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
ctx.Redirect("/admin/auths")
}
-func DeleteAuthSource(ctx *middleware.Context, params martini.Params) {
+func DeleteAuthSource(ctx *middleware.Context) {
ctx.Data["Title"] = "Delete Authentication"
ctx.Data["PageIsAuths"] = true
- id, err := base.StrTo(params["authid"]).Int64()
+ id, err := com.StrTo(ctx.Params(":authid")).Int64()
if err != nil {
ctx.Handle(404, "admin.auths.DeleteAuth", err)
return
@@ -188,7 +188,7 @@ func DeleteAuthSource(ctx *middleware.Context, params martini.Params) {
switch err {
case models.ErrAuthenticationUserUsed:
ctx.Flash.Error("This authentication still has used by some users, you should move them and then delete again.")
- ctx.Redirect("/admin/auths/" + params["authid"])
+ ctx.Redirect("/admin/auths/" + ctx.Params(":authid"))
default:
ctx.Handle(500, "admin.auths.DeleteAuth(DelLoginSource)", err)
}
diff --git a/routers/admin/user.go b/routers/admin/user.go
index 2d22cfdd89..0355632b53 100644
--- a/routers/admin/user.go
+++ b/routers/admin/user.go
@@ -7,7 +7,7 @@ package admin
import (
"strings"
- "github.com/go-martini/martini"
+ "github.com/Unknwon/com"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
@@ -42,7 +42,7 @@ func NewUserPost(ctx *middleware.Context, form auth.RegisterForm) {
return
}
- if form.Password != form.RetypePasswd {
+ if form.Password != form.Retype {
ctx.Data["Err_Password"] = true
ctx.Data["Err_RetypePasswd"] = true
ctx.RenderWithErr("Password and re-type password are not same.", "admin/users/new", &form)
@@ -60,14 +60,13 @@ func NewUserPost(ctx *middleware.Context, form auth.RegisterForm) {
if len(form.LoginType) > 0 {
// NOTE: need rewrite.
fields := strings.Split(form.LoginType, "-")
- tp, _ := base.StrTo(fields[0]).Int()
+ tp, _ := com.StrTo(fields[0]).Int()
u.LoginType = models.LoginType(tp)
- u.LoginSource, _ = base.StrTo(fields[1]).Int64()
+ u.LoginSource, _ = com.StrTo(fields[1]).Int64()
u.LoginName = form.LoginName
}
- var err error
- if u, err = models.CreateUser(u); err != nil {
+ if err := models.CreateUser(u); err != nil {
switch err {
case models.ErrUserAlreadyExist:
ctx.RenderWithErr("Username has been already taken", USER_NEW, &form)
@@ -87,11 +86,11 @@ func NewUserPost(ctx *middleware.Context, form auth.RegisterForm) {
ctx.Redirect("/admin/users")
}
-func EditUser(ctx *middleware.Context, params martini.Params) {
+func EditUser(ctx *middleware.Context) {
ctx.Data["Title"] = "Edit Account"
ctx.Data["PageIsUsers"] = true
- uid, err := base.StrTo(params["userid"]).Int()
+ uid, err := com.StrTo(ctx.Params(":userid")).Int()
if err != nil {
ctx.Handle(404, "admin.user.EditUser", err)
return
@@ -113,11 +112,11 @@ func EditUser(ctx *middleware.Context, params martini.Params) {
ctx.HTML(200, USER_EDIT)
}
-func EditUserPost(ctx *middleware.Context, params martini.Params, form auth.AdminEditUserForm) {
+func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) {
ctx.Data["Title"] = "Edit Account"
ctx.Data["PageIsUsers"] = true
- uid, err := base.StrTo(params["userid"]).Int()
+ uid, err := com.StrTo(ctx.Params(":userid")).Int()
if err != nil {
ctx.Handle(404, "admin.user.EditUserPost", err)
return
@@ -134,7 +133,7 @@ func EditUserPost(ctx *middleware.Context, params martini.Params, form auth.Admi
return
}
- if (form.Passwd != "") {
+ if form.Passwd != "" {
u.Passwd = form.Passwd
u.Rands = models.GetUserSalt()
u.Salt = models.GetUserSalt()
@@ -157,15 +156,15 @@ func EditUserPost(ctx *middleware.Context, params martini.Params, form auth.Admi
ctx.Data["User"] = u
ctx.Flash.Success("Account profile has been successfully updated.")
- ctx.Redirect("/admin/users/" + params["userid"])
+ ctx.Redirect("/admin/users/" + ctx.Params(":userid"))
}
-func DeleteUser(ctx *middleware.Context, params martini.Params) {
+func DeleteUser(ctx *middleware.Context) {
ctx.Data["Title"] = "Delete Account"
ctx.Data["PageIsUsers"] = true
//log.Info("delete")
- uid, err := base.StrTo(params["userid"]).Int()
+ uid, err := com.StrTo(ctx.Params(":userid")).Int()
if err != nil {
ctx.Handle(404, "admin.user.DeleteUser", err)
return
@@ -181,7 +180,7 @@ func DeleteUser(ctx *middleware.Context, params martini.Params) {
switch err {
case models.ErrUserOwnRepos:
ctx.Flash.Error("This account still has ownership of repository, owner has to delete or transfer them first.")
- ctx.Redirect("/admin/users/" + params["userid"])
+ ctx.Redirect("/admin/users/" + ctx.Params(":userid"))
default:
ctx.Handle(500, "admin.user.DeleteUser", err)
}