Browse Source

Merge pull request 'fix-687' (#1027) from fix-687 into V20211213

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/1027
Reviewed-by: lewis <747342561@qq.com>
tags/v1.21.12.1^2
lewis 4 years ago
parent
commit
41e205d4f0
1 changed files with 16 additions and 6 deletions
  1. +16
    -6
      models/user.go

+ 16
- 6
models/user.go View File

@@ -145,7 +145,7 @@ type User struct {
AllowImportLocal bool // Allow migrate repository by local path AllowImportLocal bool // Allow migrate repository by local path
AllowCreateOrganization bool `xorm:"DEFAULT true"` AllowCreateOrganization bool `xorm:"DEFAULT true"`
ProhibitLogin bool `xorm:"NOT NULL DEFAULT false"` ProhibitLogin bool `xorm:"NOT NULL DEFAULT false"`
IsOperator bool `xorm:"NOT NULL DEFAULT false"` //运营人员
IsOperator bool `xorm:"NOT NULL DEFAULT false"` //运营人员


// Avatar // Avatar
Avatar string `xorm:"VARCHAR(2048) NOT NULL"` Avatar string `xorm:"VARCHAR(2048) NOT NULL"`
@@ -929,8 +929,17 @@ var (
"template", "template",
"user", "user",
"vendor", "vendor",
}
reservedUserPatterns = []string{"*.keys", "*.gpg"}
"dashbord",
"operation",
"blockchain",
"avatar",
"swagger.v1.json",
"secure",
"serviceworker.js",
"self",
"repo-avatars",
}
reservedUserPatterns = []string{"*.keys", "*.gpg", "*.png"}
) )


// isUsableName checks if name is reserved or pattern of name is not allowed // isUsableName checks if name is reserved or pattern of name is not allowed
@@ -1552,11 +1561,11 @@ func GetUserByActivateEmail(email string) (*User, error) {
if err := ctx.e.Join("INNER", "email_address", "email_address.uid = \"user\".id"). if err := ctx.e.Join("INNER", "email_address", "email_address.uid = \"user\".id").
Where("email_address.email= ?", email). Where("email_address.email= ?", email).
Find(&users); err != nil { Find(&users); err != nil {
return nil,err
return nil, err
} }
if len(users) >= 1 { if len(users) >= 1 {
return &users[0],nil
}else {
return &users[0], nil
} else {
// Finally, if email address is the protected email address:用户邮件地址设置为隐藏电子邮件地址 // Finally, if email address is the protected email address:用户邮件地址设置为隐藏电子邮件地址
if strings.HasSuffix(email, fmt.Sprintf("@%s", setting.Service.NoReplyAddress)) { if strings.HasSuffix(email, fmt.Sprintf("@%s", setting.Service.NoReplyAddress)) {
username := strings.TrimSuffix(email, fmt.Sprintf("@%s", setting.Service.NoReplyAddress)) username := strings.TrimSuffix(email, fmt.Sprintf("@%s", setting.Service.NoReplyAddress))
@@ -1572,6 +1581,7 @@ func GetUserByActivateEmail(email string) (*User, error) {
return nil, errors.New("cannot find user by email") return nil, errors.New("cannot find user by email")
} }
} }

// GetUserByEmail returns the user object by given e-mail if exists. // GetUserByEmail returns the user object by given e-mail if exists.
func GetUserByEmail(email string) (*User, error) { func GetUserByEmail(email string) (*User, error) {
return GetUserByEmailContext(DefaultDBContext(), email) return GetUserByEmailContext(DefaultDBContext(), email)


Loading…
Cancel
Save