Fix steam id validation
This commit is contained in:
parent
23953b38dc
commit
a7fcd77e1e
@ -12,6 +12,6 @@ export default async function handler(req, res) {
|
|||||||
const isValid = await Utils.isValidSteamId(steamId);
|
const isValid = await Utils.isValidSteamId(steamId);
|
||||||
return res.json({
|
return res.json({
|
||||||
status: "OK",
|
status: "OK",
|
||||||
message: isValid ? `Invalid` : "Valid",
|
message: !isValid ? `Valid` : "Invalid",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -76,15 +76,14 @@ export default class Overlay extends Component {
|
|||||||
const id = params.id;
|
const id = params.id;
|
||||||
if (!id) {
|
if (!id) {
|
||||||
// Check if the id param is valid
|
// Check if the id param is valid
|
||||||
this.setState({ isValidSteamId: false });
|
this.setState({ isValidSteamId: false, loadingPlayerData: false });
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the steam id is valid
|
// Checks if the steam id is valid
|
||||||
const isValid = await this.validateSteamId(id);
|
const isValid = await this.validateSteamId(id);
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
this.setState({ isValidSteamId: false });
|
this.setState({ isValidSteamId: false, loadingPlayerData: false });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setState({ id: id, isValidSteamId: true });
|
this.setState({ id: id, isValidSteamId: true });
|
||||||
@ -201,9 +200,13 @@ export default class Overlay extends Component {
|
|||||||
* @param {id} The Steam ID of the player to validate
|
* @param {id} The Steam ID of the player to validate
|
||||||
*/
|
*/
|
||||||
async validateSteamId(id) {
|
async validateSteamId(id) {
|
||||||
|
if (id.length !== 17) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const data = await fetch(`/api/validateid?steamid=${id}`);
|
const data = await fetch(`/api/validateid?steamid=${id}`);
|
||||||
const json = await data.json();
|
const json = await data.json();
|
||||||
return json.message === "Valid" ? true : false;
|
console.log(json.message);
|
||||||
|
return json.message === "Valid";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,3 +14,9 @@
|
|||||||
.loading {
|
.loading {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.invalidPlayer {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user