mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-04-02 02:57:15 +08:00
PR comments
This commit is contained in:
parent
ffefd56192
commit
2e7c596f7f
111
api/endpoints.go
111
api/endpoints.go
@ -740,38 +740,36 @@ func handleAdminDiscordUnlink(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
httpError(w, r, err, http.StatusUnauthorized)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
username := r.Form.Get("username")
|
username := r.Form.Get("username")
|
||||||
discordId := r.Form.Get("discordId")
|
discordId := r.Form.Get("discordId")
|
||||||
|
|
||||||
if username != "" {
|
switch {
|
||||||
log.Printf("Username given, removing discordId")
|
case username != "":
|
||||||
// this does a quick call to make sure the username exists on the server before allowing the rest of the code to run
|
log.Printf("Username given, removing discordId")
|
||||||
// this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server
|
// this does a quick call to make sure the username exists on the server before allowing the rest of the code to run
|
||||||
_, err = db.CheckUsernameExists(username)
|
// this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server
|
||||||
if err != nil {
|
_, err = db.CheckUsernameExists(username)
|
||||||
httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound)
|
if err != nil {
|
||||||
return
|
httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound)
|
||||||
}
|
return
|
||||||
err = db.RemoveDiscordIdByUsername(username)
|
}
|
||||||
if err != nil {
|
|
||||||
httpError(w, r, err, http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if discordId != "" {
|
|
||||||
log.Printf("DiscordID given, removing discordId")
|
|
||||||
err = db.RemoveDiscordIdByDiscordId(discordId)
|
|
||||||
if err != nil {
|
|
||||||
httpError(w, r, err, http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
err = db.RemoveDiscordIdByUsername(username)
|
||||||
|
if err != nil {
|
||||||
|
httpError(w, r, err, http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case discordId != "":
|
||||||
|
log.Printf("DiscordID given, removing discordId")
|
||||||
|
err = db.RemoveDiscordIdByDiscordId(discordId)
|
||||||
|
if err != nil {
|
||||||
|
httpError(w, r, err, http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("%s: %s removed discord id %s from username %s", userDiscordId, r.URL.Path, r.Form.Get("discordId"), r.Form.Get("username"))
|
log.Printf("%s: %s removed discord id %s from username %s", userDiscordId, r.URL.Path, r.Form.Get("discordId"), r.Form.Get("username"))
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
@ -849,36 +847,34 @@ func handleAdminGoogleUnlink(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
httpError(w, r, err, http.StatusUnauthorized)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
username := r.Form.Get("username")
|
username := r.Form.Get("username")
|
||||||
googleId := r.Form.Get("googleId")
|
googleId := r.Form.Get("googleId")
|
||||||
|
|
||||||
if username != "" {
|
switch {
|
||||||
log.Printf("Username given, removing googleId")
|
case username != "":
|
||||||
// this does a quick call to make sure the username exists on the server before allowing the rest of the code to run
|
log.Printf("Username given, removing googleId")
|
||||||
// this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server
|
// this does a quick call to make sure the username exists on the server before allowing the rest of the code to run
|
||||||
_, err = db.CheckUsernameExists(username)
|
// this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server
|
||||||
if err != nil {
|
_, err = db.CheckUsernameExists(username)
|
||||||
httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound)
|
if err != nil {
|
||||||
return
|
httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound)
|
||||||
}
|
return
|
||||||
err = db.RemoveGoogleIdByUsername(username)
|
}
|
||||||
if err != nil {
|
|
||||||
httpError(w, r, err, http.StatusInternalServerError)
|
err = db.RemoveGoogleIdByUsername(username)
|
||||||
return
|
if err != nil {
|
||||||
}
|
httpError(w, r, err, http.StatusInternalServerError)
|
||||||
}
|
return
|
||||||
if googleId != "" {
|
}
|
||||||
log.Printf("DiscordID given, removing googleId")
|
|
||||||
err = db.RemoveGoogleIdByDiscordId(googleId)
|
case googleId != "":
|
||||||
if err != nil {
|
log.Printf("DiscordID given, removing googleId")
|
||||||
httpError(w, r, err, http.StatusInternalServerError)
|
err = db.RemoveGoogleIdByDiscordId(googleId)
|
||||||
return
|
if err != nil {
|
||||||
}
|
httpError(w, r, err, http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("%s: %s removed google id %s from username %s", userDiscordId, r.URL.Path, r.Form.Get("googleId"), r.Form.Get("username"))
|
log.Printf("%s: %s removed google id %s from username %s", userDiscordId, r.URL.Path, r.Form.Get("googleId"), r.Form.Get("username"))
|
||||||
@ -911,11 +907,6 @@ func handleAdminSearch(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
httpError(w, r, err, http.StatusUnauthorized)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
username := r.Form.Get("username")
|
username := r.Form.Get("username")
|
||||||
|
|
||||||
// this does a quick call to make sure the username exists on the server before allowing the rest of the code to run
|
// this does a quick call to make sure the username exists on the server before allowing the rest of the code to run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user