Should Geckos allow headers to be set in authorization? #91
-
So, I'm currently working on the piece of my game where the client needs to establish a connection to the server. The client has already authenticated with our auth system (Firebase) and is sending an auth token in the At this point there are a few different error scenarios that can occur, but the one I'm focusing on is if the user's email is not verified. The user has an account, but they haven't clicked the verify link in their email. Until they click that link, they're not allowed to connect. This is all hunky dory, except for the response to the client. My There's a relatively simple solution to this, which is just passing the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I don't fully understand your question. But can't you just do something like this? // client
const channel = geckos({ authorization: 'SECRET_CLIENT_TOKEN' })
// server
const io = geckos({
authorization: async (auth, request) => {
const clientToken = auth // SECRET_CLIENT_TOKEN
const res = await requestToFirebase({ token: clientToken })
if (res.status === 200 && res.email && res.emailIsVerified) return res
return 401 // unauthorized
}
})
io.onConnection(channel => {
console.log(channel.userData) // will be whatever is in "res"
}) |
Beta Was this translation helpful? Give feedback.
I don't fully understand your question. But can't you just do something like this?