|
|
@ -119,6 +119,10 @@ func (u *User) HomeLink() string { |
|
|
|
// AvatarLink returns user gravatar link.
|
|
|
|
// AvatarLink returns user gravatar link.
|
|
|
|
func (u *User) AvatarLink() string { |
|
|
|
func (u *User) AvatarLink() string { |
|
|
|
defaultImgUrl := setting.AppSubUrl + "/img/avatar_default.jpg" |
|
|
|
defaultImgUrl := setting.AppSubUrl + "/img/avatar_default.jpg" |
|
|
|
|
|
|
|
if u.Id == -1 { |
|
|
|
|
|
|
|
return defaultImgUrl |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
imgPath := path.Join(setting.AvatarUploadPath, com.ToStr(u.Id)) |
|
|
|
imgPath := path.Join(setting.AvatarUploadPath, com.ToStr(u.Id)) |
|
|
|
switch { |
|
|
|
switch { |
|
|
|
case u.UseCustomAvatar: |
|
|
|
case u.UseCustomAvatar: |
|
|
@ -321,6 +325,15 @@ func GetUserSalt() string { |
|
|
|
return base.GetRandomString(10) |
|
|
|
return base.GetRandomString(10) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NewFakeUser creates and returns a fake user for someone has deleted his/her account.
|
|
|
|
|
|
|
|
func NewFakeUser() *User { |
|
|
|
|
|
|
|
return &User{ |
|
|
|
|
|
|
|
Id: -1, |
|
|
|
|
|
|
|
Name: "Someone", |
|
|
|
|
|
|
|
LowerName: "someone", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// CreateUser creates record of a new user.
|
|
|
|
// CreateUser creates record of a new user.
|
|
|
|
func CreateUser(u *User) (err error) { |
|
|
|
func CreateUser(u *User) (err error) { |
|
|
|
if err = IsUsableName(u.Name); err != nil { |
|
|
|
if err = IsUsableName(u.Name); err != nil { |
|
|
@ -546,6 +559,7 @@ func DeleteUser(u *User) error { |
|
|
|
&Collaboration{UserID: u.Id}, |
|
|
|
&Collaboration{UserID: u.Id}, |
|
|
|
&EmailAddress{Uid: u.Id}, |
|
|
|
&EmailAddress{Uid: u.Id}, |
|
|
|
&Watch{UserID: u.Id}, |
|
|
|
&Watch{UserID: u.Id}, |
|
|
|
|
|
|
|
&IssueUser{UID: u.Id}, |
|
|
|
); err != nil { |
|
|
|
); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
@ -563,11 +577,16 @@ func DeleteUser(u *User) error { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
for _, key := range keys { |
|
|
|
for _, key := range keys { |
|
|
|
if err = DeletePublicKey(key); err != nil { |
|
|
|
if err = deletePublicKey(sess, key); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Clear assignee.
|
|
|
|
|
|
|
|
if _, err = sess.Exec("UPDATE `issue` SET assignee_id=0 WHERE assignee_id=?", u.Id); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if _, err = sess.Delete(u); err != nil { |
|
|
|
if _, err = sess.Delete(u); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|