api, frontend: restrict profile updates to commento provider

This commit is contained in:
Adhityaa Chandrasekar 2020-02-13 20:11:47 -05:00
parent b7c214e910
commit 986b05f89a
3 changed files with 7 additions and 3 deletions

View File

@ -54,9 +54,10 @@ func commenterUpdateHandler(w http.ResponseWriter, r *http.Request) {
} }
if c.Provider != "commento" { if c.Provider != "commento" {
*x.Link = c.Link bodyMarshal(w, response{"success": false, "message": errorCannotUpdateOauthProfile.Error()})
*x.Photo = c.Photo return
} }
*x.Email = c.Email *x.Email = c.Email
if err = commenterUpdate(c.CommenterHex, *x.Email, *x.Name, *x.Link, *x.Photo, c.Provider); err != nil { if err = commenterUpdate(c.CommenterHex, *x.Email, *x.Name, *x.Link, *x.Photo, c.Provider); err != nil {

View File

@ -49,3 +49,4 @@ var errorInvalidDomain = errors.New("Invalid domain name. Do not include the URL
var errorInvalidEntity = errors.New("That entity does not exist.") var errorInvalidEntity = errors.New("That entity does not exist.")
var errorCannotDeleteOwnerWithActiveDomains = errors.New("You cannot delete your account until all domains associated with your account are deleted.") var errorCannotDeleteOwnerWithActiveDomains = errors.New("You cannot delete your account until all domains associated with your account are deleted.")
var errorNoSuchOwner = errors.New("No such owner.") var errorNoSuchOwner = errors.New("No such owner.")
var errorCannotUpdateOauthProfile = errors.New("You cannot update the profile of an external account managed by third-party log in. Please use the appropriate platform to update your details.")

View File

@ -314,7 +314,9 @@
append(loggedInAs, name); append(loggedInAs, name);
append(loggedContainer, loggedInAs); append(loggedContainer, loggedInAs);
append(loggedContainer, logoutButton); append(loggedContainer, logoutButton);
append(loggedContainer, profileEditButton); if (commenter.provider === "commento") {
append(loggedContainer, profileEditButton);
}
append(loggedContainer, notificationSettingsButton); append(loggedContainer, notificationSettingsButton);
prepend(root, loggedContainer); prepend(root, loggedContainer);