mirror of https://github.com/gogits/gogs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
4.8 KiB
155 lines
4.8 KiB
11 years ago
|
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a MIT-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
8 years ago
|
package form
|
||
11 years ago
|
|
||
|
import (
|
||
10 years ago
|
"mime/multipart"
|
||
|
|
||
9 years ago
|
"github.com/go-macaron/binding"
|
||
|
"gopkg.in/macaron.v1"
|
||
11 years ago
|
)
|
||
|
|
||
8 years ago
|
type Install struct {
|
||
10 years ago
|
DbType string `binding:"Required"`
|
||
|
DbHost string
|
||
|
DbUser string
|
||
|
DbPasswd string
|
||
|
DbName string
|
||
10 years ago
|
SSLMode string
|
||
10 years ago
|
DbPath string
|
||
|
|
||
8 years ago
|
AppName string `binding:"Required" locale:"install.app_name"`
|
||
|
RepoRootPath string `binding:"Required"`
|
||
|
RunUser string `binding:"Required"`
|
||
|
Domain string `binding:"Required"`
|
||
|
SSHPort int
|
||
|
UseBuiltinSSHServer bool
|
||
|
HTTPPort string `binding:"Required"`
|
||
|
AppUrl string `binding:"Required"`
|
||
|
LogRootPath string `binding:"Required"`
|
||
8 years ago
|
EnableConsoleMode bool
|
||
10 years ago
|
|
||
10 years ago
|
SMTPHost string
|
||
|
SMTPFrom string
|
||
8 years ago
|
SMTPUser string `binding:"OmitEmpty;MaxSize(254)" locale:"install.mailer_user"`
|
||
10 years ago
|
SMTPPasswd string
|
||
10 years ago
|
RegisterConfirm bool
|
||
|
MailNotify bool
|
||
|
|
||
9 years ago
|
OfflineMode bool
|
||
|
DisableGravatar bool
|
||
|
EnableFederatedAvatar bool
|
||
|
DisableRegistration bool
|
||
|
EnableCaptcha bool
|
||
|
RequireSignInView bool
|
||
10 years ago
|
|
||
10 years ago
|
AdminName string `binding:"OmitEmpty;AlphaDashDot;MaxSize(30)" locale:"install.admin_name"`
|
||
9 years ago
|
AdminPasswd string `binding:"OmitEmpty;MaxSize(255)" locale:"install.admin_password"`
|
||
10 years ago
|
AdminConfirmPasswd string
|
||
9 years ago
|
AdminEmail string `binding:"OmitEmpty;MinSize(3);MaxSize(254);Include(@)" locale:"install.admin_email"`
|
||
11 years ago
|
}
|
||
|
|
||
8 years ago
|
func (f *Install) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||
10 years ago
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||
11 years ago
|
}
|
||
|
|
||
|
// _____ ____ _________________ ___
|
||
|
// / _ \ | | \__ ___/ | \
|
||
|
// / /_\ \| | / | | / ~ \
|
||
|
// / | \ | / | | \ Y /
|
||
|
// \____|__ /______/ |____| \___|_ /
|
||
|
// \/ \/
|
||
|
|
||
8 years ago
|
type Register struct {
|
||
9 years ago
|
UserName string `binding:"Required;AlphaDashDot;MaxSize(35)"`
|
||
|
Email string `binding:"Required;Email;MaxSize(254)"`
|
||
|
Password string `binding:"Required;MaxSize(255)"`
|
||
|
Retype string
|
||
11 years ago
|
}
|
||
|
|
||
8 years ago
|
func (f *Register) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||
10 years ago
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||
11 years ago
|
}
|
||
|
|
||
8 years ago
|
type SignIn struct {
|
||
9 years ago
|
UserName string `binding:"Required;MaxSize(254)"`
|
||
|
Password string `binding:"Required;MaxSize(255)"`
|
||
|
Remember bool
|
||
11 years ago
|
}
|
||
|
|
||
8 years ago
|
func (f *SignIn) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||
10 years ago
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||
11 years ago
|
}
|
||
|
|
||
|
// __________________________________________.___ _______ ________ _________
|
||
|
// / _____/\_ _____/\__ ___/\__ ___/| |\ \ / _____/ / _____/
|
||
|
// \_____ \ | __)_ | | | | | |/ | \/ \ ___ \_____ \
|
||
|
// / \ | \ | | | | | / | \ \_\ \/ \
|
||
|
// /_______ //_______ / |____| |____| |___\____|__ /\______ /_______ /
|
||
|
// \/ \/ \/ \/ \/
|
||
|
|
||
8 years ago
|
type UpdateProfile struct {
|
||
8 years ago
|
Name string `binding:"Required;AlphaDashDot;MaxSize(35)"`
|
||
9 years ago
|
FullName string `binding:"MaxSize(100)"`
|
||
|
Email string `binding:"Required;Email;MaxSize(254)"`
|
||
|
Website string `binding:"Url;MaxSize(100)"`
|
||
|
Location string `binding:"MaxSize(50)"`
|
||
11 years ago
|
}
|
||
|
|
||
8 years ago
|
func (f *UpdateProfile) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||
10 years ago
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||
11 years ago
|
}
|
||
|
|
||
9 years ago
|
const (
|
||
|
AVATAR_LOCAL string = "local"
|
||
|
AVATAR_BYMAIL string = "bymail"
|
||
|
)
|
||
|
|
||
8 years ago
|
type Avatar struct {
|
||
9 years ago
|
Source string
|
||
|
Avatar *multipart.FileHeader
|
||
|
Gravatar string `binding:"OmitEmpty;Email;MaxSize(254)"`
|
||
|
Federavatar bool
|
||
10 years ago
|
}
|
||
|
|
||
8 years ago
|
func (f *Avatar) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||
10 years ago
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||
|
}
|
||
|
|
||
8 years ago
|
type AddEmail struct {
|
||
9 years ago
|
Email string `binding:"Required;Email;MaxSize(254)"`
|
||
10 years ago
|
}
|
||
|
|
||
8 years ago
|
func (f *AddEmail) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||
10 years ago
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||
|
}
|
||
|
|
||
8 years ago
|
type ChangePassword struct {
|
||
|
OldPassword string `binding:"Required;MinSize(1);MaxSize(255)"`
|
||
|
Password string `binding:"Required;MaxSize(255)"`
|
||
|
Retype string
|
||
11 years ago
|
}
|
||
|
|
||
8 years ago
|
func (f *ChangePassword) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||
10 years ago
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||
11 years ago
|
}
|
||
10 years ago
|
|
||
8 years ago
|
type AddSSHKey struct {
|
||
10 years ago
|
Title string `binding:"Required;MaxSize(50)"`
|
||
|
Content string `binding:"Required"`
|
||
10 years ago
|
}
|
||
|
|
||
8 years ago
|
func (f *AddSSHKey) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||
10 years ago
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||
|
}
|
||
|
|
||
8 years ago
|
type NewAccessToken struct {
|
||
9 years ago
|
Name string `binding:"Required"`
|
||
10 years ago
|
}
|
||
|
|
||
8 years ago
|
func (f *NewAccessToken) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||
10 years ago
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||
|
}
|