Closed ckpiggy closed 6 years ago
Have you tested it from Chrome or Opera? Because if the sending takes some time then Chrome performs request again.... Try to simulate it from another script or from another browser..... or please create a small example.
BTW: you can't use json
with post
flag because post
is listening on json
and urlencode
automatically.
I found it is because I call twice next
in my F.onAuthorize
delegate
F.onAuthorize = async function (req, res, flags, next) {
let user
try {
const data = decryptToken(req)
user = await findUserByTokenData(data)
flags.push(`@${user.role}`)
} catch (e) {
next(false)
} finally {
next(true, user)
}
}
If auth failed, next
will called in catch block and finally block.
But I am also curious about "Will the routes doesn't have authorized flag trigger the authorize delegate?"
It seems every route will trigger the delegate and ignore the callback result if the route doesn't have authorized
flag
onAuthorize
must be executed every request because the routing depends on it. So it doesn't matter if you have authorize
, unauthorize
flag or no.
Thank you @petersirka
I created an api to send sms
I found the schema.insert function was called twice in a single request. But when I test with
GETSCHEMA
The insert function only called once.