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.

publickey.go 872B

123456789101112131415161718192021222324252627282930313233
  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. "net/http"
  7. "reflect"
  8. "github.com/go-martini/martini"
  9. "github.com/gogits/gogs/modules/base"
  10. "github.com/gogits/gogs/modules/middleware/binding"
  11. )
  12. type AddSSHKeyForm struct {
  13. KeyName string `form:"keyname" binding:"Required"`
  14. KeyContent string `form:"key_content" binding:"Required"`
  15. }
  16. func (f *AddSSHKeyForm) Name(field string) string {
  17. names := map[string]string{
  18. "KeyName": "SSH key name",
  19. "KeyContent": "SSH key content",
  20. }
  21. return names[field]
  22. }
  23. func (f *AddSSHKeyForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
  24. data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  25. validate(errors, data, f)
  26. }