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.

user_form.go 3.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. Host string `form:"host"`
  13. User string `form:"user"`
  14. Passwd 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"`
  19. RunUser string `form:"run_user"`
  20. Domain string `form:"domain"`
  21. AppUrl string `form:"app_url"`
  22. AdminName string `form:"admin_name" binding:"Required;AlphaDashDot;MaxSize(30)"`
  23. AdminPasswd string `form:"admin_pwd" binding:"Required;MinSize(6);MaxSize(30)"`
  24. AdminEmail string `form:"admin_email" binding:"Required;Email;MaxSize(50)"`
  25. SmtpHost string `form:"smtp_host"`
  26. SmtpEmail string `form:"mailer_user"`
  27. SmtpPasswd string `form:"mailer_pwd"`
  28. RegisterConfirm string `form:"register_confirm"`
  29. MailNotify string `form:"mail_notify"`
  30. }
  31. func (f *InstallForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  32. validate(errs, ctx.Data, f, l)
  33. }
  34. // _____ ____ _________________ ___
  35. // / _ \ | | \__ ___/ | \
  36. // / /_\ \| | / | | / ~ \
  37. // / | \ | / | | \ Y /
  38. // \____|__ /______/ |____| \___|_ /
  39. // \/ \/
  40. type RegisterForm struct {
  41. UserName string `form:"uname" binding:"Required;AlphaDashDot;MaxSize(35)"`
  42. Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
  43. Password string `form:"password" binding:"Required;MinSize(6);MaxSize(30)"`
  44. Retype string `form:"retype"`
  45. LoginType string `form:"logintype"`
  46. LoginName string `form:"loginname"`
  47. }
  48. func (f *RegisterForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  49. validate(errs, ctx.Data, f, l)
  50. }
  51. type SignInForm struct {
  52. UserName string `form:"uname" binding:"Required;MaxSize(35)"`
  53. Password string `form:"password" binding:"Required;MinSize(6);MaxSize(30)"`
  54. Remember bool `form:"remember"`
  55. }
  56. func (f *SignInForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  57. validate(errs, ctx.Data, f, l)
  58. }
  59. // __________________________________________.___ _______ ________ _________
  60. // / _____/\_ _____/\__ ___/\__ ___/| |\ \ / _____/ / _____/
  61. // \_____ \ | __)_ | | | | | |/ | \/ \ ___ \_____ \
  62. // / \ | \ | | | | | / | \ \_\ \/ \
  63. // /_______ //_______ / |____| |____| |___\____|__ /\______ /_______ /
  64. // \/ \/ \/ \/ \/
  65. type UpdateProfileForm struct {
  66. UserName string `form:"uname" binding:"Required;MaxSize(35)"`
  67. FullName string `form:"fullname" binding:"MaxSize(40)"`
  68. Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
  69. Website string `form:"website" binding:"Url;MaxSize(50)"`
  70. Location string `form:"location" binding:"MaxSize(50)"`
  71. Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"`
  72. }
  73. func (f *UpdateProfileForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  74. validate(errs, ctx.Data, f, l)
  75. }
  76. type ChangePasswordForm struct {
  77. OldPassword string `form:"old_password" binding:"Required;MinSize(6);MaxSize(30)"`
  78. Password string `form:"password" binding:"Required;MinSize(6);MaxSize(30)"`
  79. Retype string `form:"retype"`
  80. }
  81. func (f *ChangePasswordForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  82. validate(errs, ctx.Data, f, l)
  83. }