Browse Source

steam auth 3

master
gsd 2 years ago
parent
commit
dfc6cfb0ce
  1. 20
      src/main/java/app/controllers/auth/AuthSteamController.java

20
src/main/java/app/controllers/auth/AuthSteamController.java

@ -4,6 +4,7 @@ import app.annotations.enums.AuthMethod;
import app.annotations.exceptions.InvalidCookie;
import app.annotations.exceptions.NeedCookie;
import app.annotations.interfaces.CheckWebAccess;
import app.entities.other.SteamID;
import app.services.db.DiscordAuthService;
import app.services.steam.SteamSignIn;
import app.services.steam.SteamWebApi;
@ -108,4 +109,23 @@ public class AuthSteamController {
if (discord_id != null) return new ResponseEntity(discord_id, HttpStatus.OK);
else return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
@DeleteMapping("steam/discord")
public ResponseEntity unregisterDiscordUser(@CookieValue(value = "steam64", defaultValue = "") String steam64,
@CookieValue(value = "steam64_secured", defaultValue = "") String steam64_secured){
if (steam64.isEmpty() || steam64_secured.isEmpty()) {
throw new NeedCookie();
}
if (!saltedCookie.Validate(steam64, steam64_secured)) {
throw new InvalidCookie();
}
SteamID steamID = SteamIDConverter.getSteamID(steam64);
String discord_id = discordAuthService.getDiscordIDofSteamID(steamID);
if (discord_id == null) return new ResponseEntity(HttpStatus.NOT_FOUND);
boolean result = discordAuthService.removeSteamIDofDiscordID(steamID);
return new ResponseEntity(result, HttpStatus.OK);
}
}

Loading…
Cancel
Save