0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-31 06:32:37 +00:00

Initial pass at ID validations

This commit is contained in:
G.Ambatte
2025-07-10 19:59:09 +12:00
parent 7ba7991631
commit aa15bdaacb
2 changed files with 29 additions and 0 deletions

View File

@@ -48,6 +48,15 @@ const api = {
}
id = id.slice(googleId.length);
}
// ID Validation Checks
if(!id.match(/^[A-Za-z0-9_-]{12}$/)){
throw { name: 'ID Error', message: 'Invalid ID', status: 404, HBErrorCode: '11', brewId: id };
}
if(googleId && !googleId.match(/^1(?:[A-Za-z0-9+\/]{32}|[A-Za-z0-9+\/]{43})$/)){
throw { name: 'Google ID Error', message: 'Invalid ID', status: 404, HBErrorCode: '12', brewId: id };
}
return { id, googleId };
},
//Get array of any of this user's brews tagged with `meta:theme`