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.

99 lines
4.0 KiB

10 years ago
10 years ago
10 years ago
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package auth
  5. import (
  6. "github.com/Unknwon/macaron"
  7. "github.com/macaron-contrib/i18n"
  8. "github.com/gogits/gogs/modules/middleware/binding"
  9. )
  10. type InstallForm struct {
  11. Database string `form:"database" binding:"Required"`
  12. DbHost string `form:"host"`
  13. DbUser string `form:"user"`
  14. DbPasswd string `form:"passwd"`
  15. DatabaseName string `form:"database_name"`
  16. SslMode string `form:"ssl_mode"`
  17. DatabasePath string `form:"database_path"`
  18. RepoRootPath string `form:"repo_path" binding:"Required"`
  19. RunUser string `form:"run_user" binding:"Required"`
  20. Domain string `form:"domain" binding:"Required"`
  21. AppUrl string `form:"app_url" binding:"Required"`
  22. SmtpHost string `form:"smtp_host"`
  23. SmtpEmail string `form:"mailer_user"`
  24. SmtpPasswd string `form:"mailer_pwd"`
  25. RegisterConfirm string `form:"register_confirm"`
  26. MailNotify string `form:"mail_notify"`
  27. AdminName string `form:"admin_name" binding:"Required;AlphaDashDot;MaxSize(30)"`
  28. AdminPasswd string `form:"admin_pwd" binding:"Required;MinSize(6);MaxSize(255)"`
  29. ConfirmPasswd string `form:"confirm_passwd" binding:"Required;MinSize(6);MaxSize(255)"`
  30. AdminEmail string `form:"admin_email" binding:"Required;Email;MaxSize(50)"`
  31. }
  32. func (f *InstallForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  33. validate(errs, ctx.Data, f, l)
  34. }
  35. // _____ ____ _________________ ___
  36. // / _ \ | | \__ ___/ | \
  37. // / /_\ \| | / | | / ~ \
  38. // / | \ | / | | \ Y /
  39. // \____|__ /______/ |____| \___|_ /
  40. // \/ \/
  41. type RegisterForm struct {
  42. UserName string `form:"uname" binding:"Required;AlphaDashDot;MaxSize(35)"`
  43. Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
  44. Password string `form:"password" binding:"Required;MinSize(6);MaxSize(255)"`
  45. Retype string `form:"retype"`
  46. LoginType string `form:"logintype"`
  47. LoginName string `form:"loginname"`
  48. }
  49. func (f *RegisterForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  50. validate(errs, ctx.Data, f, l)
  51. }
  52. type SignInForm struct {
  53. UserName string `form:"uname" binding:"Required;MaxSize(35)"`
  54. Password string `form:"password" binding:"Required;MinSize(6);MaxSize(255)"`
  55. Remember bool `form:"remember"`
  56. }
  57. func (f *SignInForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  58. validate(errs, ctx.Data, f, l)
  59. }
  60. // __________________________________________.___ _______ ________ _________
  61. // / _____/\_ _____/\__ ___/\__ ___/| |\ \ / _____/ / _____/
  62. // \_____ \ | __)_ | | | | | |/ | \/ \ ___ \_____ \
  63. // / \ | \ | | | | | / | \ \_\ \/ \
  64. // /_______ //_______ / |____| |____| |___\____|__ /\______ /_______ /
  65. // \/ \/ \/ \/ \/
  66. type UpdateProfileForm struct {
  67. UserName string `form:"uname" binding:"Required;MaxSize(35)"`
  68. FullName string `form:"fullname" binding:"MaxSize(100)"`
  69. Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
  70. Website string `form:"website" binding:"Url;MaxSize(100)"`
  71. Location string `form:"location" binding:"MaxSize(50)"`
  72. Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"`
  73. }
  74. func (f *UpdateProfileForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  75. validate(errs, ctx.Data, f, l)
  76. }
  77. type ChangePasswordForm struct {
  78. OldPassword string `form:"old_password" binding:"Required;MinSize(6);MaxSize(255)"`
  79. Password string `form:"password" binding:"Required;MinSize(6);MaxSize(255)"`
  80. Retype string `form:"retype"`
  81. }
  82. func (f *ChangePasswordForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  83. validate(errs, ctx.Data, f, l)
  84. }