#697 disable captcha and new admin create user UI
This commit is contained in:
parent
e2d6b0116e
commit
8e0a69f86a
|
@ -99,6 +99,8 @@ ENABLE_REVERSE_PROXY_AUTHENTICATION = false
|
||||||
ENABLE_REVERSE_PROXY_AUTO_REGISTRATION = false
|
ENABLE_REVERSE_PROXY_AUTO_REGISTRATION = false
|
||||||
; Do not check minimum key size with corresponding type
|
; Do not check minimum key size with corresponding type
|
||||||
DISABLE_MINIMUM_KEY_SIZE_CHECK = false
|
DISABLE_MINIMUM_KEY_SIZE_CHECK = false
|
||||||
|
; Disable captcha validation for registration
|
||||||
|
DISABLE_CAPTCHA = false
|
||||||
|
|
||||||
[webhook]
|
[webhook]
|
||||||
; Hook task queue length
|
; Hook task queue length
|
||||||
|
|
|
@ -780,6 +780,7 @@ users.activated = Activated
|
||||||
users.admin = Admin
|
users.admin = Admin
|
||||||
users.repos = Repos
|
users.repos = Repos
|
||||||
users.created = Created
|
users.created = Created
|
||||||
|
users.new_success = New account '%s' has been created successfully.
|
||||||
users.edit = Edit
|
users.edit = Edit
|
||||||
users.auth_source = Authentication Source
|
users.auth_source = Authentication Source
|
||||||
users.local = Local
|
users.local = Local
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.6.11.0912 Beta"
|
const APP_VER = "0.6.11.0913 Beta"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -175,7 +175,7 @@ func CreateSource(source *LoginSource) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAuths() ([]*LoginSource, error) {
|
func LoginSources() ([]*LoginSource, error) {
|
||||||
auths := make([]*LoginSource, 0, 5)
|
auths := make([]*LoginSource, 0, 5)
|
||||||
return auths, x.Find(&auths)
|
return auths, x.Find(&auths)
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,12 +58,12 @@ func (f *InstallForm) Validate(ctx *macaron.Context, errs binding.Errors) bindin
|
||||||
// \/ \/
|
// \/ \/
|
||||||
|
|
||||||
type RegisterForm struct {
|
type RegisterForm struct {
|
||||||
UserName string `form:"uname" binding:"Required;AlphaDashDot;MaxSize(35)"`
|
UserName string `binding:"Required;AlphaDashDot;MaxSize(35)"`
|
||||||
Email string `form:"email" binding:"Required;Email;MaxSize(254)"`
|
Email string `binding:"Required;Email;MaxSize(254)"`
|
||||||
Password string `form:"password" binding:"Required;MaxSize(255)"`
|
Password string `binding:"Required;MaxSize(255)"`
|
||||||
Retype string `form:"retype"`
|
Retype string
|
||||||
LoginType string `form:"logintype"`
|
LoginType string
|
||||||
LoginName string `form:"loginname"`
|
LoginName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *RegisterForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
func (f *RegisterForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -27,6 +27,10 @@ type ToggleOptions struct {
|
||||||
|
|
||||||
// AutoSignIn reads cookie and try to auto-login.
|
// AutoSignIn reads cookie and try to auto-login.
|
||||||
func AutoSignIn(ctx *Context) (bool, error) {
|
func AutoSignIn(ctx *Context) (bool, error) {
|
||||||
|
if !models.HasEngine {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
uname := ctx.GetCookie(setting.CookieUserName)
|
uname := ctx.GetCookie(setting.CookieUserName)
|
||||||
if len(uname) == 0 {
|
if len(uname) == 0 {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|
|
@ -421,6 +421,7 @@ var Service struct {
|
||||||
EnableReverseProxyAuth bool
|
EnableReverseProxyAuth bool
|
||||||
EnableReverseProxyAutoRegister bool
|
EnableReverseProxyAutoRegister bool
|
||||||
DisableMinimumKeySizeCheck bool
|
DisableMinimumKeySizeCheck bool
|
||||||
|
DisableCaptcha bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newService() {
|
func newService() {
|
||||||
|
@ -434,6 +435,7 @@ func newService() {
|
||||||
Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
|
Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
|
||||||
Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
|
Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
|
||||||
Service.DisableMinimumKeySizeCheck = sec.Key("DISABLE_MINIMUM_KEY_SIZE_CHECK").MustBool()
|
Service.DisableMinimumKeySizeCheck = sec.Key("DISABLE_MINIMUM_KEY_SIZE_CHECK").MustBool()
|
||||||
|
Service.DisableCaptcha = sec.Key("DISABLE_CAPTCHA").MustBool()
|
||||||
}
|
}
|
||||||
|
|
||||||
var logLevels = map[string]string{
|
var logLevels = map[string]string{
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -147,11 +147,20 @@ function initInstall() {
|
||||||
|
|
||||||
// Database type change detection.
|
// Database type change detection.
|
||||||
$("#db_type").change(function () {
|
$("#db_type").change(function () {
|
||||||
|
var sqlite_default = 'data/gogs.db';
|
||||||
|
var tidb_default = 'data/gogs_tidb';
|
||||||
|
|
||||||
var db_type = $(this).val();
|
var db_type = $(this).val();
|
||||||
if (db_type === "SQLite3" || db_type === "TiDB") {
|
if (db_type === "SQLite3" || db_type === "TiDB") {
|
||||||
$('#sql_settings').hide();
|
$('#sql_settings').hide();
|
||||||
$('#pgsql_settings').hide();
|
$('#pgsql_settings').hide();
|
||||||
$('#sqlite_settings').show();
|
$('#sqlite_settings').show();
|
||||||
|
|
||||||
|
if (db_type === "SQLite3" && $('#db_path').val() == tidb_default) {
|
||||||
|
$('#db_path').val(sqlite_default);
|
||||||
|
} else if (db_type === "TiDB" && $('#db_path').val() == sqlite_default) {
|
||||||
|
$('#db_path').val(tidb_default);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,31 +457,46 @@ function initAdmin() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New user
|
||||||
|
if ($('.admin.new.user').length > 0) {
|
||||||
|
$('#login_type').change(function () {
|
||||||
|
if ($(this).val().substring(0, 1) == '0') {
|
||||||
|
$('#login_name').removeAttr('required');
|
||||||
|
$('#password').attr('required', 'required');
|
||||||
|
$('.non-local').hide();
|
||||||
|
$('.local').show();
|
||||||
|
$('#user_name').focus();
|
||||||
|
} else {
|
||||||
|
$('#login_name').attr('required', 'required');
|
||||||
|
$('#password').removeAttr('required');
|
||||||
|
$('.non-local').show();
|
||||||
|
$('.local').hide();
|
||||||
|
$('#login_name').focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// New authentication
|
// New authentication
|
||||||
if ($('.admin.new.authentication').length > 0) {
|
if ($('.admin.new.authentication').length > 0) {
|
||||||
$('#auth_type').change(function () {
|
$('#auth_type').change(function () {
|
||||||
|
$('.ldap').hide();
|
||||||
|
$('.dldap').hide();
|
||||||
|
$('.smtp').hide();
|
||||||
|
$('.pam').hide();
|
||||||
|
|
||||||
var auth_type = $(this).val();
|
var auth_type = $(this).val();
|
||||||
switch (auth_type) {
|
switch (auth_type) {
|
||||||
case '2': // LDAP
|
case '2': // LDAP
|
||||||
$('.dldap').hide();
|
|
||||||
$('.smtp').hide();
|
|
||||||
$('.pam').hide();
|
|
||||||
$('.ldap').show();
|
$('.ldap').show();
|
||||||
break;
|
break;
|
||||||
case '3': // SMTP
|
case '3': // SMTP
|
||||||
$('.ldap').hide();
|
|
||||||
$('.pam').hide();
|
|
||||||
$('.smtp').show();
|
$('.smtp').show();
|
||||||
break;
|
break;
|
||||||
case '4': // PAM
|
case '4': // PAM
|
||||||
$('.ldap').hide();
|
|
||||||
$('.smtp').hide();
|
|
||||||
$('.pam').show();
|
$('.pam').show();
|
||||||
break;
|
break;
|
||||||
case '5': // LDAP
|
case '5': // LDAP
|
||||||
$('.ldap').hide();
|
|
||||||
$('.smtp').hide();
|
|
||||||
$('.pam').hide();
|
|
||||||
$('.dldap').show();
|
$('.dldap').show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,20 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.signup {
|
||||||
|
@input-padding: 200px!important;
|
||||||
|
#create-page-form;
|
||||||
|
form {
|
||||||
|
width: 700px!important;
|
||||||
|
.header {
|
||||||
|
padding-left: @input-padding+30px;
|
||||||
|
}
|
||||||
|
.inline.field > label {
|
||||||
|
width: @input-padding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.repository {
|
.repository {
|
||||||
&.new.repo,
|
&.new.repo,
|
||||||
&.new.migrate,
|
&.new.migrate,
|
||||||
|
|
|
@ -31,4 +31,9 @@
|
||||||
a {
|
a {
|
||||||
color: #d9453d;
|
color: #d9453d;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.signup {
|
||||||
|
padding-top: 15px;
|
||||||
|
padding-bottom: @footer-margin * 2;
|
||||||
}
|
}
|
|
@ -29,9 +29,9 @@ func Authentications(ctx *middleware.Context) {
|
||||||
ctx.Data["PageIsAdminAuthentications"] = true
|
ctx.Data["PageIsAdminAuthentications"] = true
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
ctx.Data["Sources"], err = models.GetAuths()
|
ctx.Data["Sources"], err = models.LoginSources()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "GetAuths", err)
|
ctx.Handle(500, "LoginSources", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
|
@ -14,6 +16,23 @@ const (
|
||||||
REPOS base.TplName = "admin/repo/list"
|
REPOS base.TplName = "admin/repo/list"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func pagination(ctx *middleware.Context, count int64, pageNum int) int {
|
||||||
|
p := ctx.QueryInt("p")
|
||||||
|
if p < 1 {
|
||||||
|
p = 1
|
||||||
|
}
|
||||||
|
curCount := int64((p-1)*pageNum + pageNum)
|
||||||
|
if curCount >= count {
|
||||||
|
p = int(math.Ceil(float64(count) / float64(pageNum)))
|
||||||
|
} else {
|
||||||
|
ctx.Data["NextPageNum"] = p + 1
|
||||||
|
}
|
||||||
|
if p > 1 {
|
||||||
|
ctx.Data["LastPageNum"] = p - 1
|
||||||
|
}
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
func Repositories(ctx *middleware.Context) {
|
func Repositories(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("admin.repositories")
|
ctx.Data["Title"] = ctx.Tr("admin.repositories")
|
||||||
ctx.Data["PageIsAdmin"] = true
|
ctx.Data["PageIsAdmin"] = true
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Unknwon/com"
|
"github.com/Unknwon/com"
|
||||||
|
@ -25,23 +24,6 @@ const (
|
||||||
USER_EDIT base.TplName = "admin/user/edit"
|
USER_EDIT base.TplName = "admin/user/edit"
|
||||||
)
|
)
|
||||||
|
|
||||||
func pagination(ctx *middleware.Context, count int64, pageNum int) int {
|
|
||||||
p := ctx.QueryInt("p")
|
|
||||||
if p < 1 {
|
|
||||||
p = 1
|
|
||||||
}
|
|
||||||
curCount := int64((p-1)*pageNum + pageNum)
|
|
||||||
if curCount >= count {
|
|
||||||
p = int(math.Ceil(float64(count) / float64(pageNum)))
|
|
||||||
} else {
|
|
||||||
ctx.Data["NextPageNum"] = p + 1
|
|
||||||
}
|
|
||||||
if p > 1 {
|
|
||||||
ctx.Data["LastPageNum"] = p - 1
|
|
||||||
}
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
func Users(ctx *middleware.Context) {
|
func Users(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("admin.users")
|
ctx.Data["Title"] = ctx.Tr("admin.users")
|
||||||
ctx.Data["PageIsAdmin"] = true
|
ctx.Data["PageIsAdmin"] = true
|
||||||
|
@ -70,12 +52,14 @@ func NewUser(ctx *middleware.Context) {
|
||||||
ctx.Data["PageIsAdmin"] = true
|
ctx.Data["PageIsAdmin"] = true
|
||||||
ctx.Data["PageIsAdminUsers"] = true
|
ctx.Data["PageIsAdminUsers"] = true
|
||||||
|
|
||||||
auths, err := models.GetAuths()
|
ctx.Data["login_type"] = "0-0"
|
||||||
|
|
||||||
|
sources, err := models.LoginSources()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "GetAuths", err)
|
ctx.Handle(500, "LoginSources", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Data["LoginSources"] = auths
|
ctx.Data["Sources"] = sources
|
||||||
ctx.HTML(200, USER_NEW)
|
ctx.HTML(200, USER_NEW)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,14 +68,15 @@ func NewUserPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||||
ctx.Data["PageIsAdmin"] = true
|
ctx.Data["PageIsAdmin"] = true
|
||||||
ctx.Data["PageIsAdminUsers"] = true
|
ctx.Data["PageIsAdminUsers"] = true
|
||||||
|
|
||||||
if ctx.HasError() {
|
sources, err := models.LoginSources()
|
||||||
ctx.HTML(200, USER_NEW)
|
if err != nil {
|
||||||
|
ctx.Handle(500, "LoginSources", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ctx.Data["Sources"] = sources
|
||||||
|
|
||||||
if form.Password != form.Retype {
|
if ctx.HasError() {
|
||||||
ctx.Data["Err_Password"] = true
|
ctx.HTML(200, USER_NEW)
|
||||||
ctx.RenderWithErr(ctx.Tr("form.password_not_match"), USER_NEW, &form)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,12 +89,12 @@ func NewUserPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(form.LoginType) > 0 {
|
if len(form.LoginType) > 0 {
|
||||||
// NOTE: need rewrite.
|
|
||||||
fields := strings.Split(form.LoginType, "-")
|
fields := strings.Split(form.LoginType, "-")
|
||||||
tp, _ := com.StrTo(fields[0]).Int()
|
if len(fields) == 2 {
|
||||||
u.LoginType = models.LoginType(tp)
|
u.LoginType = models.LoginType(com.StrTo(fields[0]).MustInt())
|
||||||
u.LoginSource, _ = com.StrTo(fields[1]).Int64()
|
u.LoginSource = com.StrTo(fields[1]).MustInt64()
|
||||||
u.LoginName = form.LoginName
|
u.LoginName = form.LoginName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := models.CreateUser(u); err != nil {
|
if err := models.CreateUser(u); err != nil {
|
||||||
|
@ -132,7 +117,9 @@ func NewUserPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Trace("Account created by admin(%s): %s", ctx.User.Name, u.Name)
|
log.Trace("Account created by admin(%s): %s", ctx.User.Name, u.Name)
|
||||||
ctx.Redirect(setting.AppSubUrl + "/admin/users")
|
|
||||||
|
ctx.Flash.Success(ctx.Tr("admin.users.new_success", u.Name))
|
||||||
|
ctx.Redirect(setting.AppSubUrl + "/admin/users/" + com.ToStr(u.Id))
|
||||||
}
|
}
|
||||||
|
|
||||||
func EditUser(ctx *middleware.Context) {
|
func EditUser(ctx *middleware.Context) {
|
||||||
|
@ -151,14 +138,14 @@ func EditUser(ctx *middleware.Context) {
|
||||||
ctx.Handle(500, "GetUserByID", err)
|
ctx.Handle(500, "GetUserByID", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["User"] = u
|
ctx.Data["User"] = u
|
||||||
auths, err := models.GetAuths()
|
|
||||||
|
sources, err := models.LoginSources()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "GetAuths", err)
|
ctx.Handle(500, "LoginSources", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Data["LoginSources"] = auths
|
ctx.Data["LoginSources"] = sources
|
||||||
ctx.HTML(200, USER_EDIT)
|
ctx.HTML(200, USER_EDIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,8 @@ func oauthSignUp(ctx *middleware.Context, sid int64) {
|
||||||
func SignUp(ctx *middleware.Context) {
|
func SignUp(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("sign_up")
|
ctx.Data["Title"] = ctx.Tr("sign_up")
|
||||||
|
|
||||||
|
ctx.Data["DisableCaptcha"] = setting.Service.DisableCaptcha
|
||||||
|
|
||||||
if setting.Service.DisableRegistration {
|
if setting.Service.DisableRegistration {
|
||||||
ctx.Data["DisableRegistration"] = true
|
ctx.Data["DisableRegistration"] = true
|
||||||
ctx.HTML(200, SIGNUP)
|
ctx.HTML(200, SIGNUP)
|
||||||
|
@ -168,6 +170,8 @@ func SignUp(ctx *middleware.Context) {
|
||||||
func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.RegisterForm) {
|
func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.RegisterForm) {
|
||||||
ctx.Data["Title"] = ctx.Tr("sign_up")
|
ctx.Data["Title"] = ctx.Tr("sign_up")
|
||||||
|
|
||||||
|
ctx.Data["DisableCaptcha"] = setting.Service.DisableCaptcha
|
||||||
|
|
||||||
if setting.Service.DisableRegistration {
|
if setting.Service.DisableRegistration {
|
||||||
ctx.Error(403)
|
ctx.Error(403)
|
||||||
return
|
return
|
||||||
|
@ -179,36 +183,18 @@ func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.Registe
|
||||||
ctx.Data["IsSocialLogin"] = true
|
ctx.Data["IsSocialLogin"] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// May redirect from home page.
|
|
||||||
if ctx.Query("from") == "home" {
|
|
||||||
// Clear input error box.
|
|
||||||
ctx.Data["Err_UserName"] = false
|
|
||||||
ctx.Data["Err_Email"] = false
|
|
||||||
|
|
||||||
// Make the best guess.
|
|
||||||
uname := ctx.Query("uname")
|
|
||||||
i := strings.Index(uname, "@")
|
|
||||||
if i > -1 {
|
|
||||||
ctx.Data["email"] = uname
|
|
||||||
ctx.Data["uname"] = uname[:i]
|
|
||||||
} else {
|
|
||||||
ctx.Data["uname"] = uname
|
|
||||||
}
|
|
||||||
ctx.Data["password"] = ctx.Query("password")
|
|
||||||
ctx.HTML(200, SIGNUP)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, SIGNUP)
|
ctx.HTML(200, SIGNUP)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cpt.VerifyReq(ctx.Req) {
|
if !setting.Service.DisableCaptcha && !cpt.VerifyReq(ctx.Req) {
|
||||||
ctx.Data["Err_Captcha"] = true
|
ctx.Data["Err_Captcha"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), SIGNUP, &form)
|
ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), SIGNUP, &form)
|
||||||
return
|
return
|
||||||
} else if form.Password != form.Retype {
|
}
|
||||||
|
|
||||||
|
if form.Password != form.Retype {
|
||||||
ctx.Data["Err_Password"] = true
|
ctx.Data["Err_Password"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("form.password_not_match"), SIGNUP, &form)
|
ctx.RenderWithErr(ctx.Tr("form.password_not_match"), SIGNUP, &form)
|
||||||
return
|
return
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.6.11.0912 Beta
|
0.6.11.0913 Beta
|
|
@ -1,58 +1,56 @@
|
||||||
{{template "ng/base/head" .}}
|
{{template "base/head" .}}
|
||||||
{{template "ng/base/header" .}}
|
<div class="admin new user">
|
||||||
<div id="admin-wrapper">
|
<div class="ui container">
|
||||||
<div id="setting-wrapper" class="main-wrapper">
|
<div class="ui grid">
|
||||||
<div id="admin-setting" class="container clear">
|
{{template "admin/navbar" .}}
|
||||||
{{template "admin/nav" .}}
|
<div class="twelve wide column content">
|
||||||
<div class="grid-4-5 left">
|
{{template "base/alert" .}}
|
||||||
<div class="setting-content">
|
<h4 class="ui top attached header">
|
||||||
{{template "ng/base/alert" .}}
|
{{.i18n.Tr "admin.users.new_account"}}
|
||||||
<div id="setting-content">
|
</h4>
|
||||||
<div class="panel panel-radius">
|
<div class="ui attached segment">
|
||||||
<div class="panel-header">
|
<form class="ui form" action="{{.Link}}" method="post">
|
||||||
<strong>{{.i18n.Tr "admin.users.new_account"}}</strong>
|
{{.CsrfTokenHtml}}
|
||||||
</div>
|
<!-- Types and name -->
|
||||||
<form class="form form-align panel-body" id="repo-setting-form" action="{{AppSubUrl}}/admin/users/new" method="post">
|
<div class="inline required field {{if .Err_LoginType}}error{{end}}">
|
||||||
{{.CsrfTokenHtml}}
|
<label>{{.i18n.Tr "admin.users.auth_source"}}</label>
|
||||||
<div class="field">
|
<div class="ui selection type dropdown">
|
||||||
<label class="req">{{.i18n.Tr "admin.users.auth_source"}}</label>
|
<input type="hidden" id="login_type" name="login_type" value="{{.login_type}}-{{.login_id}}" required>
|
||||||
<select id="login-type" name="logintype">
|
<div class="text">{{.i18n.Tr "admin.users.local"}}</div>
|
||||||
<option value="0-0">{{.i18n.Tr "admin.users.local"}}</option>
|
<i class="dropdown icon"></i>
|
||||||
{{range $key, $val := .LoginSources}}
|
<div class="menu">
|
||||||
<option value="{{$val.Type}}-{{$val.ID}}">{{$val.Name}}</option>
|
<div class="item" data-value="0-0">{{.i18n.Tr "admin.users.local"}}</div>
|
||||||
{{end}}
|
{{range .Sources}}
|
||||||
</select>
|
<div class="item" data-value="{{.Type}}-{{.ID}}">{{.Name}}</div>
|
||||||
</div>
|
{{end}}
|
||||||
<div class="field auth-name hidden">
|
|
||||||
<label class="req" for="loginname">{{.i18n.Tr "admin.users.auth_login_name"}}</label>
|
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_LoginName}}ipt-error{{end}}" id="loginname" name="loginname" value="{{.loginname}}" />
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<label class="req" for="username">{{.i18n.Tr "username"}}</label>
|
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_UserName}}ipt-error{{end}}" id="username" name="uname" type="text" value="{{.uname}}" required />
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<label class="req" for="email">{{.i18n.Tr "email"}}</label>
|
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_Email}}ipt-error{{end}}" id="email" name="email" type="email" value="{{.email}}" required/>
|
|
||||||
</div>
|
|
||||||
<div class="field pwd">
|
|
||||||
<label class="req" for="password">{{.i18n.Tr "password"}}</label>
|
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_Password}}ipt-error{{end}}" id="password" name="password" type="password" value="{{.password}}" required/>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<label class="req" for="re-type">{{.i18n.Tr "re_type"}}</label>
|
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_Password}}ipt-error{{end}}" id="re-type" name="retype" type="password" required/>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<label></label>
|
|
||||||
<button class="btn btn-blue btn-large btn-radius">{{.i18n.Tr "admin.users.new_account"}}</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="required non-local field {{if .Err_LoginName}}error{{end}} {{if not (eq .login_type "0-0")}}hide{{end}}">
|
||||||
|
<label for="login_name">{{.i18n.Tr "admin.users.auth_login_name"}}</label>
|
||||||
|
<input id="login_name" name="login_name" value="{{.login_name}}">
|
||||||
|
</div>
|
||||||
|
<div class="required field {{if .Err_UserName}}error{{end}}">
|
||||||
|
<label for="user_name">{{.i18n.Tr "username"}}</label>
|
||||||
|
<input id="user_name" name="user_name" value="{{.user_name}}" autofocus required>
|
||||||
|
</div>
|
||||||
|
<div class="required field {{if .Err_Email}}error{{end}}">
|
||||||
|
<label for="email">{{.i18n.Tr "email"}}</label>
|
||||||
|
<input id="email" name="email" type="email" value="{{.email}}" required>
|
||||||
|
</div>
|
||||||
|
<input class="fake" type="password">
|
||||||
|
<div class="required local field {{if .Err_Password}}error{{end}} {{if eq .login_type "0-0"}}hide{{end}}">
|
||||||
|
<label for="password">{{.i18n.Tr "password"}}</label>
|
||||||
|
<input id="password" name="password" type="password" value="{{.password}}" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<button class="ui green button">{{.i18n.Tr "admin.users.new_account"}}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{template "ng/base/footer" .}}
|
{{template "base/footer" .}}
|
|
@ -1,49 +1,56 @@
|
||||||
{{template "ng/base/head" .}}
|
{{template "base/head" .}}
|
||||||
{{template "ng/base/header" .}}
|
<div class="signup">
|
||||||
<div id="sign-wrapper">
|
<div class="ui middle very relaxed page grid">
|
||||||
<form class="form-align form panel panel-radius sign-panel sign-form container" id="sign-up-form" action="{{AppSubUrl}}/user/sign_up" method="post">
|
<div class="column">
|
||||||
<div class="panel-header">
|
<form class="ui form" action="{{.Link}}" method="post">
|
||||||
<h2>{{if .IsSocialLogin}}{{.i18n.Tr "social_sign_in" | Str2html}}{{else}}{{.i18n.Tr "sign_up"}}{{end}}</h2>
|
{{.CsrfTokenHtml}}
|
||||||
</div>
|
<h3 class="ui top attached header">
|
||||||
<div class="panel-content">
|
{{if .IsSocialLogin}}{{.i18n.Tr "social_sign_in" | Str2html}}{{else}}{{.i18n.Tr "sign_up"}}{{end}}
|
||||||
{{template "ng/base/alert" .}}
|
</h3>
|
||||||
|
<div class="ui attached segment">
|
||||||
|
{{template "base/alert" .}}
|
||||||
{{if .DisableRegistration}}
|
{{if .DisableRegistration}}
|
||||||
<p>{{.i18n.Tr "auth.disable_register_prompt"}}</p>
|
<p>{{.i18n.Tr "auth.disable_register_prompt"}}</p>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="field">
|
<div class="required inline field {{if .Err_UserName}}error{{end}}">
|
||||||
<label class="req" for="username">{{.i18n.Tr "username"}}</label>
|
<label for="user_name">{{.i18n.Tr "username"}}</label>
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_UserName}}ipt-error{{end}}" id="username" name="uname" type="text" value="{{.uname}}" required/>
|
<input id="user_name" name="user_name" value="{{.user_name}}" autofocus required>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="required inline field {{if .Err_Email}}error{{end}}">
|
||||||
<label class="req" for="email">{{.i18n.Tr "email"}}</label>
|
<label for="email">{{.i18n.Tr "email"}}</label>
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_Email}}ipt-error{{end}}" id="email" name="email" type="email" value="{{.email}}" required />
|
<input id="email" name="email" type="email" value="{{.email}}" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="required inline field {{if .Err_Password}}error{{end}}">
|
||||||
<label class="req" for="password">{{.i18n.Tr "password"}}</label>
|
<label for="password">{{.i18n.Tr "password"}}</label>
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_Password}}ipt-error{{end}}" id="password" name="password" type="password" value="{{.password}}" required/>
|
<input id="password" name="password" type="password" value="{{.password}}" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="required inline field {{if .Err_Password}}error{{end}}">
|
||||||
<label class="req" for="re-type">{{.i18n.Tr "re_type"}}</label>
|
<label for="retype">{{.i18n.Tr "re_type"}}</label>
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_Password}}ipt-error{{end}}" id="re-type" name="retype" type="password" required/>
|
<input id="retype" name="retype" type="password" value="{{.retype}}" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
{{if not .DisableCaptcha}}
|
||||||
<label></label>
|
<div class="inline field">
|
||||||
{{.Captcha.CreateHtml}}
|
<label></label>
|
||||||
</div>
|
{{.Captcha.CreateHtml}}
|
||||||
<div class="field">
|
</div>
|
||||||
<label class="req" for="captcha">{{.i18n.Tr "captcha"}}</label>
|
<div class="required inline field {{if .Err_Captcha}}error{{end}}">
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_Captcha}}ipt-error{{end}}" id="captcha" name="captcha" type="text" required/>
|
<label for="captcha">{{.i18n.Tr "captcha"}}</label>
|
||||||
</div>
|
<input id="captcha" name="captcha" value="{{.captcha}}" autocomplete="off">
|
||||||
<div class="field">
|
</div>
|
||||||
<span class="form-label"></span>
|
{{end}}
|
||||||
<button class="btn btn-blue btn-large btn-radius">{{.i18n.Tr "auth.create_new_account"}}</button>
|
|
||||||
</div>
|
<div class="inline field">
|
||||||
<div class="field">
|
<label></label>
|
||||||
<span class="form-label"></span>
|
<button class="ui green button">{{.i18n.Tr "auth.create_new_account"}}</button>
|
||||||
<a href="{{AppSubUrl}}/user/login">{{if .IsSocialLogin}}{{.i18n.Tr "auth.social_register_hepler_msg"}}{{else}}{{.i18n.Tr "auth.register_hepler_msg"}}{{end}}</a>
|
</div>
|
||||||
</div>
|
<div class="inline field">
|
||||||
|
<label></label>
|
||||||
|
<a href="{{AppSubUrl}}/user/login">{{if .IsSocialLogin}}{{.i18n.Tr "auth.social_register_hepler_msg"}}{{else}}{{.i18n.Tr "auth.register_hepler_msg"}}{{end}}</a>
|
||||||
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{template "ng/base/footer" .}}
|
{{template "base/footer" .}}
|
Loading…
Reference in New Issue