code.gitea.io/gitea@v1.21.7/services/forms/user_form_auth_openid.go (about)

     1  // Copyright 2017 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package forms
     5  
     6  import (
     7  	"net/http"
     8  
     9  	"code.gitea.io/gitea/modules/context"
    10  	"code.gitea.io/gitea/modules/web/middleware"
    11  
    12  	"gitea.com/go-chi/binding"
    13  )
    14  
    15  // SignInOpenIDForm form for signing in with OpenID
    16  type SignInOpenIDForm struct {
    17  	Openid   string `binding:"Required;MaxSize(256)"`
    18  	Remember bool
    19  }
    20  
    21  // Validate validates the fields
    22  func (f *SignInOpenIDForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
    23  	ctx := context.GetValidateContext(req)
    24  	return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
    25  }
    26  
    27  // SignUpOpenIDForm form for signin up with OpenID
    28  type SignUpOpenIDForm struct {
    29  	UserName string `binding:"Required;Username;MaxSize(40)"`
    30  	Email    string `binding:"Required;Email;MaxSize(254)"`
    31  }
    32  
    33  // Validate validates the fields
    34  func (f *SignUpOpenIDForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
    35  	ctx := context.GetValidateContext(req)
    36  	return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
    37  }
    38  
    39  // ConnectOpenIDForm form for connecting an existing account to an OpenID URI
    40  type ConnectOpenIDForm struct {
    41  	UserName string `binding:"Required;MaxSize(254)"`
    42  	Password string `binding:"Required;MaxSize(255)"`
    43  }
    44  
    45  // Validate validates the fields
    46  func (f *ConnectOpenIDForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
    47  	ctx := context.GetValidateContext(req)
    48  	return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
    49  }