Merge pull request #5 from armisss4/revert-2-User-control-patch

Revert "User control patch"
This commit is contained in:
Arminas 2023-01-04 12:54:37 +02:00 committed by GitHub
commit b06eb96e9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -215,10 +215,7 @@ func UpdateUser(db store.IStore) echo.HandlerFunc {
}
user.PasswordHash = hash
}
if previousUsername != currentUser(c) {
user.Admin = admin
}
if err := db.DeleteUser(previousUsername); err != nil {
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, err.Error()})
@ -292,10 +289,6 @@ func RemoveUser(db store.IStore) echo.HandlerFunc {
}
username := data["username"].(string)
if username == currentUser(c) {
return c.JSON(http.StatusForbidden, jsonHTTPResponse{false, "User cannot delete itself"})
}
// delete user from database
if err := db.DeleteUser(username); err != nil {
@ -304,7 +297,10 @@ func RemoveUser(db store.IStore) echo.HandlerFunc {
}
log.Infof("Removed user: %s", username)
if username == currentUser(c) {
log.Infof("You removed yourself, killing session")
clearSession(c)
}
return c.JSON(http.StatusOK, jsonHTTPResponse{true, "User removed"})
}
}