forked from forgejo/forgejo
Added: Ability to delete org avatar.
This commit is contained in:
parent
c2ca103d30
commit
9c91e27933
5 changed files with 26 additions and 6 deletions
|
@ -346,6 +346,19 @@ func (u *User) UploadAvatar(data []byte) error {
|
|||
return sess.Commit()
|
||||
}
|
||||
|
||||
// DeleteAvatar deletes the user's custom avatar.
|
||||
func (u *User) DeleteAvatar() error {
|
||||
log.Info("Deleting user avatar: %s", u.CustomAvatarPath())
|
||||
os.Remove(u.CustomAvatarPath())
|
||||
|
||||
u.UseCustomAvatar = false
|
||||
if err := UpdateUser(u); err != nil {
|
||||
return fmt.Errorf("updateUser: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsAdminOfRepo returns true if user has admin or higher access of repository.
|
||||
func (u *User) IsAdminOfRepo(repo *Repository) bool {
|
||||
has, err := HasAccess(u, repo, ACCESS_MODE_ADMIN)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue