|
|
@ -751,34 +751,34 @@ func handleAdminDiscordUnlink(w http.ResponseWriter, r *http.Request) {
|
|
|
|
discordId := r.Form.Get("discordId")
|
|
|
|
discordId := r.Form.Get("discordId")
|
|
|
|
|
|
|
|
|
|
|
|
switch {
|
|
|
|
switch {
|
|
|
|
case username != "":
|
|
|
|
case username != "":
|
|
|
|
log.Printf("Username given, removing discordId")
|
|
|
|
log.Printf("Username given, removing discordId")
|
|
|
|
// 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
|
|
|
|
// this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server
|
|
|
|
// this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server
|
|
|
|
_, err = db.CheckUsernameExists(username)
|
|
|
|
_, err = db.CheckUsernameExists(username)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound)
|
|
|
|
httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
userUuid, err := db.FetchUUIDFromUsername(username)
|
|
|
|
userUuid, err := db.FetchUUIDFromUsername(username)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err = db.RemoveDiscordIdByUUID(userUuid)
|
|
|
|
err = db.RemoveDiscordIdByUUID(userUuid)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case discordId != "":
|
|
|
|
case discordId != "":
|
|
|
|
log.Printf("DiscordID given, removing discordId")
|
|
|
|
log.Printf("DiscordID given, removing discordId")
|
|
|
|
err = db.RemoveDiscordIdByDiscordId(discordId)
|
|
|
|
err = db.RemoveDiscordIdByDiscordId(discordId)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
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"))
|
|
|
@ -868,34 +868,34 @@ func handleAdminGoogleUnlink(w http.ResponseWriter, r *http.Request) {
|
|
|
|
googleId := r.Form.Get("googleId")
|
|
|
|
googleId := r.Form.Get("googleId")
|
|
|
|
|
|
|
|
|
|
|
|
switch {
|
|
|
|
switch {
|
|
|
|
case username != "":
|
|
|
|
case username != "":
|
|
|
|
log.Printf("Username given, removing googleId")
|
|
|
|
log.Printf("Username given, removing googleId")
|
|
|
|
// 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
|
|
|
|
// this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server
|
|
|
|
// this calls error value 404 (StatusNotFound) if there's no data; this means the username does not exist in the server
|
|
|
|
_, err = db.CheckUsernameExists(username)
|
|
|
|
_, err = db.CheckUsernameExists(username)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound)
|
|
|
|
httpError(w, r, fmt.Errorf("username does not exist on the server"), http.StatusNotFound)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
userUuid, err := db.FetchUUIDFromUsername(username)
|
|
|
|
userUuid, err := db.FetchUUIDFromUsername(username)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err = db.RemoveGoogleIdByUUID(userUuid)
|
|
|
|
err = db.RemoveGoogleIdByUUID(userUuid)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case googleId != "":
|
|
|
|
case googleId != "":
|
|
|
|
log.Printf("DiscordID given, removing googleId")
|
|
|
|
log.Printf("DiscordID given, removing googleId")
|
|
|
|
err = db.RemoveGoogleIdByDiscordId(googleId)
|
|
|
|
err = db.RemoveGoogleIdByDiscordId(googleId)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
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"))
|
|
|
|