|
-
-
-
-
-
- package auth
-
- import (
- "mime/multipart"
- "strings"
-
- "code.gitea.io/gitea/modules/setting"
-
- "gitea.com/macaron/binding"
- "gitea.com/macaron/macaron"
- )
-
-
- type InstallForm struct {
- DbType string `binding:"Required"`
- DbHost string
- DbUser string
- DbPasswd string
- DbName string
- SSLMode string
- Charset string `binding:"Required;In(utf8,utf8mb4)"`
- DbPath string
-
- AppName string `binding:"Required" locale:"install.app_name"`
- RepoRootPath string `binding:"Required"`
- LFSRootPath string
- RunUser string `binding:"Required"`
- Domain string `binding:"Required"`
- SSHPort int
- HTTPPort string `binding:"Required"`
- AppURL string `binding:"Required"`
- LogRootPath string `binding:"Required"`
-
- SMTPHost string
- SMTPFrom string
- SMTPUser string `binding:"OmitEmpty;MaxSize(254)" locale:"install.mailer_user"`
- SMTPPasswd string
- RegisterConfirm bool
- MailNotify bool
-
- OfflineMode bool
- DisableGravatar bool
- EnableFederatedAvatar bool
- EnableOpenIDSignIn bool
- EnableOpenIDSignUp bool
- DisableRegistration bool
- AllowOnlyExternalRegistration bool
- EnableCaptcha bool
- RequireSignInView bool
- DefaultKeepEmailPrivate bool
- DefaultAllowCreateOrganization bool
- DefaultEnableTimetracking bool
- NoReplyAddress string
-
- AdminName string `binding:"OmitEmpty;AlphaDashDot;MaxSize(30)" locale:"install.admin_name"`
- AdminPasswd string `binding:"OmitEmpty;MaxSize(255)" locale:"install.admin_password"`
- AdminConfirmPasswd string
- AdminEmail string `binding:"OmitEmpty;MinSize(3);MaxSize(254);Include(@)" locale:"install.admin_email"`
- }
-
-
- func (f *InstallForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
-
-
-
-
-
-
-
- type RegisterForm struct {
- UserName string `binding:"Required;AlphaDashDot;MaxSize(40)"`
- Email string `binding:"Required;Email;MaxSize(254)"`
- Password string `binding:"MaxSize(255)"`
- Retype string
- GRecaptchaResponse string `form:"g-recaptcha-response"`
- }
-
-
- func (f *RegisterForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
-
-
-
- func (f RegisterForm) IsEmailDomainWhitelisted() bool {
- if len(setting.Service.EmailDomainWhitelist) == 0 {
- return true
- }
-
- n := strings.LastIndex(f.Email, "@")
- if n <= 0 {
- return false
- }
-
- domain := strings.ToLower(f.Email[n+1:])
-
- for _, v := range setting.Service.EmailDomainWhitelist {
- if strings.ToLower(v) == domain {
- return true
- }
- }
-
- return false
- }
-
-
-
- type MustChangePasswordForm struct {
- Password string `binding:"Required;MaxSize(255)"`
- Retype string
- }
-
-
- func (f *MustChangePasswordForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type SignInForm struct {
- UserName string `binding:"Required;MaxSize(254)"`
-
- Password string `binding:"Required;MaxSize(255)"`
- Remember bool
- }
-
-
- func (f *SignInForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type AuthorizationForm struct {
- ResponseType string `binding:"Required;In(code)"`
- ClientID string `binding:"Required"`
- RedirectURI string
- State string
-
-
- CodeChallengeMethod string
- CodeChallenge string
- }
-
-
- func (f *AuthorizationForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type GrantApplicationForm struct {
- ClientID string `binding:"Required"`
- RedirectURI string
- State string
- }
-
-
- func (f *GrantApplicationForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type AccessTokenForm struct {
- GrantType string `json:"grant_type"`
- ClientID string `json:"client_id"`
- ClientSecret string `json:"client_secret"`
- RedirectURI string `json:"redirect_uri"`
- Code string `json:"code"`
- RefreshToken string `json:"refresh_token"`
-
-
- CodeVerifier string `json:"code_verifier"`
- }
-
-
- func (f *AccessTokenForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
-
-
-
-
-
-
-
- type UpdateProfileForm struct {
- Name string `binding:"AlphaDashDot;MaxSize(40)"`
- FullName string `binding:"MaxSize(100)"`
- Email string `binding:"Required;Email;MaxSize(254)"`
- KeepEmailPrivate bool
- Website string `binding:"ValidUrl;MaxSize(255)"`
- Location string `binding:"MaxSize(50)"`
- Language string `binding:"Size(5)"`
- Description string `binding:"MaxSize(255)"`
- }
-
-
- func (f *UpdateProfileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- const (
- AvatarLocal string = "local"
- AvatarByMail string = "bymail"
- )
-
-
- type AvatarForm struct {
- Source string
- Avatar *multipart.FileHeader
- Gravatar string `binding:"OmitEmpty;Email;MaxSize(254)"`
- Federavatar bool
- }
-
-
- func (f *AvatarForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type AddEmailForm struct {
- Email string `binding:"Required;Email;MaxSize(254)"`
- }
-
-
- func (f *AddEmailForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type UpdateThemeForm struct {
- Theme string `binding:"Required;MaxSize(30)"`
- }
-
-
- func (f *UpdateThemeForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- func (f UpdateThemeForm) IsThemeExists() bool {
- var exists bool
-
- for _, v := range setting.UI.Themes {
- if strings.EqualFold(v, f.Theme) {
- exists = true
- break
- }
- }
-
- return exists
- }
-
-
- type ChangePasswordForm struct {
- OldPassword string `form:"old_password" binding:"MaxSize(255)"`
- Password string `form:"password" binding:"Required;MaxSize(255)"`
- Retype string `form:"retype"`
- }
-
-
- func (f *ChangePasswordForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type AddOpenIDForm struct {
- Openid string `binding:"Required;MaxSize(256)"`
- }
-
-
- func (f *AddOpenIDForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type AddKeyForm struct {
- Type string `binding:"OmitEmpty"`
- Title string `binding:"Required;MaxSize(50)"`
- Content string `binding:"Required"`
- IsWritable bool
- }
-
-
- func (f *AddKeyForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type NewAccessTokenForm struct {
- Name string `binding:"Required;MaxSize(255)"`
- }
-
-
- func (f *NewAccessTokenForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type EditOAuth2ApplicationForm struct {
- Name string `binding:"Required;MaxSize(255)" form:"application_name"`
- RedirectURI string `binding:"Required" form:"redirect_uri"`
- }
-
-
- func (f *EditOAuth2ApplicationForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type TwoFactorAuthForm struct {
- Passcode string `binding:"Required"`
- }
-
-
- func (f *TwoFactorAuthForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type TwoFactorScratchAuthForm struct {
- Token string `binding:"Required"`
- }
-
-
- func (f *TwoFactorScratchAuthForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type U2FRegistrationForm struct {
- Name string `binding:"Required"`
- }
-
-
- func (f *U2FRegistrationForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
-
- type U2FDeleteForm struct {
- ID int64 `binding:"Required"`
- }
-
-
- func (f *U2FDeleteForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
-
- type SearchRecords struct {
- FromId string
- ToId string
- Why string
- }
-
-
- func (f *SearchRecords) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
- return validate(errs, ctx.Data, f, ctx.Locale)
- }
|