aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorTamás Molnár <moltam@gmail.com>2016-03-06 17:36:30 +0100
committerTamás Molnár <moltam@gmail.com>2016-03-06 17:36:30 +0100
commit9c91e279338f4d8bf09e1f7f5904d34cd525b102 (patch)
tree32882aa197724e0f75608c9bfd16a24650b7be22 /models
parentc2ca103d30b0f47b5ad0fa544ab5a07263894ea3 (diff)
downloadgitea-9c91e279338f4d8bf09e1f7f5904d34cd525b102.tar.gz
gitea-9c91e279338f4d8bf09e1f7f5904d34cd525b102.zip
Added: Ability to delete org avatar.
Diffstat (limited to 'models')
-rw-r--r--models/user.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/models/user.go b/models/user.go
index bd4cace44d..8b90687e32 100644
--- a/models/user.go
+++ b/models/user.go
@@ -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)