Public Access
fix(settings): keep Steam ID as string and store the new token
Number("76561198005679788") is 76561198005679790 in JavaScript, so the wrong
Steam ID was saved. The Steam ID now stays a 17-digit string. Theme and
language saves no longer send steamId 0. After a save the new token from Auth
replaces the old one.
Add Vitest and run it in CI.
This commit is contained in:
1 parent
2c1f22f4b4
commit
44e23de6d6
6 files changed
+343
-22
No files matched your search
@@ -15,14 +15,12 @@ const inviteCodeField = z
|
||||
.string()
|
||||
.min(1, 'VALIDATION.INVITE_CODE_REQUIRED');
|
||||
|
||||
// Backend stores steamId as a primitive long; Steam IDs are positive 64-bit integers.
|
||||
// A SteamID64 has 17 digits. Keep it a string: a JS number loses precision above 2^53.
|
||||
const steamIdField = z
|
||||
.union([z.string(), z.number()])
|
||||
.transform((v) => (typeof v === 'string' ? v.trim() : String(v)))
|
||||
.refine((v) => v.length > 0, {message: 'VALIDATION.STEAM_ID_REQUIRED'})
|
||||
.refine((v) => /^\d+$/.test(v), {message: 'VALIDATION.STEAM_ID_INVALID'})
|
||||
.transform((v) => Number(v))
|
||||
.refine((n) => Number.isFinite(n) && n > 0, {message: 'VALIDATION.STEAM_ID_INVALID'});
|
||||
.string()
|
||||
.trim()
|
||||
.min(1, 'VALIDATION.STEAM_ID_REQUIRED')
|
||||
.regex(/^\d{17}$/, 'VALIDATION.STEAM_ID_INVALID');
|
||||
|
||||
export const registrationSchema = z
|
||||
.object({
|
||||
|
||||
Reference in new issue
Block a user