aboutsummaryrefslogtreecommitdiffstats
path: root/models/user.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/user.go')
-rw-r--r--models/user.go48
1 files changed, 16 insertions, 32 deletions
diff --git a/models/user.go b/models/user.go
index aaf2320b42..da9411dcb6 100644
--- a/models/user.go
+++ b/models/user.go
@@ -138,6 +138,22 @@ func (u *User) BeforeUpdate() {
if u.MaxRepoCreation < -1 {
u.MaxRepoCreation = -1
}
+
+ // Organization does not need email
+ u.Email = strings.ToLower(u.Email)
+ if !u.IsOrganization() {
+ if len(u.AvatarEmail) == 0 {
+ u.AvatarEmail = u.Email
+ }
+ if len(u.AvatarEmail) > 0 {
+ u.Avatar = base.HashEmail(u.AvatarEmail)
+ }
+ }
+
+ u.LowerName = strings.ToLower(u.Name)
+ u.Location = base.TruncateString(u.Location, 255)
+ u.Website = base.TruncateString(u.Website, 255)
+ u.Description = base.TruncateString(u.Description, 255)
}
// SetLastLogin set time to last login
@@ -840,22 +856,6 @@ func checkDupEmail(e Engine, u *User) error {
}
func updateUser(e Engine, u *User) error {
- // Organization does not need email
- u.Email = strings.ToLower(u.Email)
- if !u.IsOrganization() {
- if len(u.AvatarEmail) == 0 {
- u.AvatarEmail = u.Email
- }
- if len(u.AvatarEmail) > 0 {
- u.Avatar = base.HashEmail(u.AvatarEmail)
- }
- }
-
- u.LowerName = strings.ToLower(u.Name)
- u.Location = base.TruncateString(u.Location, 255)
- u.Website = base.TruncateString(u.Website, 255)
- u.Description = base.TruncateString(u.Description, 255)
-
_, err := e.ID(u.ID).AllCols().Update(u)
return err
}
@@ -871,22 +871,6 @@ func UpdateUserCols(u *User, cols ...string) error {
}
func updateUserCols(e Engine, u *User, cols ...string) error {
- // Organization does not need email
- u.Email = strings.ToLower(u.Email)
- if !u.IsOrganization() {
- if len(u.AvatarEmail) == 0 {
- u.AvatarEmail = u.Email
- }
- if len(u.AvatarEmail) > 0 {
- u.Avatar = base.HashEmail(u.AvatarEmail)
- }
- }
-
- u.LowerName = strings.ToLower(u.Name)
- u.Location = base.TruncateString(u.Location, 255)
- u.Website = base.TruncateString(u.Website, 255)
- u.Description = base.TruncateString(u.Description, 255)
-
_, err := e.ID(u.ID).Cols(cols...).Update(u)
return err
}