summaryrefslogtreecommitdiffstats
path: root/routers/admin
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-09-10 17:11:41 -0400
committerUnknwon <u@gogs.io>2015-09-10 17:11:41 -0400
commit06174482826e81fb7c4675efff092e2986c4dac0 (patch)
treedda3e0393111ab21789784316e2463bd920430e9 /routers/admin
parentfa728d8dff2ddb8039efc2767f4fefb2d2f62004 (diff)
downloadgitea-06174482826e81fb7c4675efff092e2986c4dac0.tar.gz
gitea-06174482826e81fb7c4675efff092e2986c4dac0.zip
finish new add auth UI
Diffstat (limited to 'routers/admin')
-rw-r--r--routers/admin/auths.go35
1 files changed, 26 insertions, 9 deletions
diff --git a/routers/admin/auths.go b/routers/admin/auths.go
index f71b786e85..f62a9e3c2b 100644
--- a/routers/admin/auths.go
+++ b/routers/admin/auths.go
@@ -39,11 +39,28 @@ func Authentications(ctx *middleware.Context) {
ctx.HTML(200, AUTHS)
}
+type AuthSource struct {
+ Name string
+ Type models.LoginType
+}
+
+var authSources = []AuthSource{
+ {models.LoginNames[models.LDAP], models.LDAP},
+ {models.LoginNames[models.DLDAP], models.DLDAP},
+ {models.LoginNames[models.SMTP], models.SMTP},
+ {models.LoginNames[models.PAM], models.PAM},
+}
+
func NewAuthSource(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("admin.auths.new")
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminAuthentications"] = true
- ctx.Data["LoginTypes"] = models.LoginTypes
+
+ ctx.Data["type"] = models.LDAP
+ ctx.Data["CurTypeName"] = models.LoginNames[models.LDAP]
+ ctx.Data["smtp_auth"] = "PLAIN"
+ ctx.Data["is_active"] = true
+ ctx.Data["AuthSources"] = authSources
ctx.Data["SMTPAuths"] = models.SMTPAuths
ctx.HTML(200, AUTH_NEW)
}
@@ -52,7 +69,9 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
ctx.Data["Title"] = ctx.Tr("admin.auths.new")
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminAuthentications"] = true
- ctx.Data["LoginTypes"] = models.LoginTypes
+
+ ctx.Data["CurTypeName"] = models.LoginNames[models.LoginType(form.Type)]
+ ctx.Data["AuthSources"] = authSources
ctx.Data["SMTPAuths"] = models.SMTPAuths
if ctx.HasError() {
@@ -62,9 +81,7 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
var u core.Conversion
switch models.LoginType(form.Type) {
- case models.LDAP:
- fallthrough
- case models.DLDAP:
+ case models.LDAP, models.DLDAP:
u = &models.LDAPConfig{
Ldapsource: ldap.Ldapsource{
Name: form.Name,
@@ -103,7 +120,7 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
var source = &models.LoginSource{
Type: models.LoginType(form.Type),
Name: form.Name,
- IsActived: true,
+ IsActived: form.IsActive,
AllowAutoRegister: form.AllowAutoRegister,
Cfg: u,
}
@@ -121,7 +138,7 @@ func EditAuthSource(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("admin.auths.edit")
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminAuthentications"] = true
- ctx.Data["LoginTypes"] = models.LoginTypes
+ // ctx.Data["LoginTypes"] = models.LoginTypes
ctx.Data["SMTPAuths"] = models.SMTPAuths
id := com.StrTo(ctx.Params(":authid")).MustInt64()
@@ -143,7 +160,7 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminAuthentications"] = true
ctx.Data["PageIsAuths"] = true
- ctx.Data["LoginTypes"] = models.LoginTypes
+ // ctx.Data["LoginTypes"] = models.LoginTypes
ctx.Data["SMTPAuths"] = models.SMTPAuths
if ctx.HasError() {
@@ -194,7 +211,7 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
u := models.LoginSource{
ID: form.ID,
Name: form.Name,
- IsActived: form.IsActived,
+ IsActived: form.IsActive,
Type: models.LoginType(form.Type),
AllowAutoRegister: form.AllowAutoRegister,
Cfg: config,