Continued work on remember me tokens.
This commit is contained in:
parent
95ed2fa403
commit
e00e5a608b
11 changed files with 113 additions and 36 deletions
|
|
@ -177,19 +177,41 @@ module.exports.rank = function(field = 'rank'){
|
|||
});
|
||||
}
|
||||
|
||||
module.exports.securityToken = function(field = 'token'){
|
||||
return checkSchema({
|
||||
[field]: {
|
||||
escape: true,
|
||||
trim: true,
|
||||
isHexadecimal: true,
|
||||
isLength: {
|
||||
options: {
|
||||
min: 64,
|
||||
max: 64
|
||||
}
|
||||
},
|
||||
errorMessage: "Invalid security token."
|
||||
const securityTokenSchema = {
|
||||
escape: true,
|
||||
trim: true,
|
||||
isHexadecimal: true,
|
||||
isLength: {
|
||||
options: {
|
||||
min: 64,
|
||||
max: 64
|
||||
}
|
||||
});
|
||||
},
|
||||
errorMessage: "Invalid security token."
|
||||
}
|
||||
|
||||
module.exports.securityToken = function(field = 'token'){
|
||||
return checkSchema({[field]:securityTokenSchema});
|
||||
}
|
||||
|
||||
module.exports.rememberMeID = function(field = 'rememberme.id'){
|
||||
return checkSchema({
|
||||
[field]:{
|
||||
in: ['cookies'],
|
||||
optional: true,
|
||||
isUUID: true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.rememberMeToken = function(field = 'rememberme.token'){
|
||||
//Create our own schema with blackjack and hookers
|
||||
const tokenSchema = structuredClone(securityTokenSchema);
|
||||
|
||||
//Modify as needed
|
||||
tokenSchema.in = ['cookies'];
|
||||
tokenSchema.optional = true;
|
||||
|
||||
//Return the validator
|
||||
return checkSchema({[field]:tokenSchema});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue