Fix avatar reupload
This commit is contained in:
1 parent
e45959ddd9
commit
0f0eb39b37
1 file changed
+9
@@ -66,12 +66,21 @@ func (s *WebService) HandleProfileEdit(w http.ResponseWriter, r *http.Request) {
|
||||
s.render(w, r, "profile/edit.html", data)
|
||||
return
|
||||
}
|
||||
// Check if the user already has an avatar; if so update, otherwise insert.
|
||||
if _, err := s.users.GetAvatar(r.Context(), data.User.Id); err == nil {
|
||||
if err := s.users.UpdateAvatar(r.Context(), data.User.Id, bytes); err != nil {
|
||||
data.Error = "Could not save avatar"
|
||||
s.render(w, r, "profile/edit.html", data)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if err := s.users.CreateAvatar(r.Context(), data.User.Id, bytes); err != nil {
|
||||
data.Error = "Could not save avatar"
|
||||
s.render(w, r, "profile/edit.html", data)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/profile", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user