oauth.go 854 B

1234567891011121314151617181920212223242526272829303132333435
  1. package admin
  2. import "Gwen/model"
  3. type BindOauthForm struct {
  4. Op string `json:"op" binding:"required"`
  5. }
  6. type OauthConfirmForm struct {
  7. Code string `json:"code" binding:"required"`
  8. }
  9. type UnBindOauthForm struct {
  10. Op string `json:"op" binding:"required"`
  11. }
  12. type OauthForm struct {
  13. Id uint `json:"id"`
  14. Op string `json:"op" validate:"required"`
  15. ClientId string `json:"client_id" validate:"required"`
  16. ClientSecret string `json:"client_secret" validate:"required"`
  17. RedirectUrl string `json:"redirect_url" validate:"required"`
  18. AutoRegister *bool `json:"auto_register"`
  19. }
  20. func (of *OauthForm) ToOauth() *model.Oauth {
  21. oa := &model.Oauth{
  22. Op: of.Op,
  23. ClientId: of.ClientId,
  24. ClientSecret: of.ClientSecret,
  25. RedirectUrl: of.RedirectUrl,
  26. AutoRegister: of.AutoRegister,
  27. }
  28. oa.Id = of.Id
  29. return oa
  30. }