1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-19 08:48:37 +00:00

Added: Ability to delete org avatar.

This commit is contained in:
Tamás Molnár
2016-03-06 17:36:30 +01:00
parent c2ca103d30
commit 9c91e27933
5 changed files with 26 additions and 6 deletions

View File

@@ -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)