Answer the question
In order to leave comments, you need to log in
How does the server get the jwt from the client?
For me, the following is magic:
I need to get the jwt when a user requests a page from me.
Where can I extract the jwt from the request?
If so, how does the browser know that I need to pass jwt ?
I sketched out a pseudo-code code to more accurately explain my idea
when the user enters the address, I meet him with the IndexHandler functions
and check if there are jwt GetClientToken () functions, but I don’t know how to check for the presence of a token (
func IndexHandler(writer http.ResponseWriter, request *http.Request) {
if request.Method != "GET"{ return}else {
// проверить наличие и валидность токена
token,res := utils.GetClientToken()
if res != true {
render.DefaultIndexRender(writer)
return
}
// если токен есть извлекаем из него данные
uid,err := utils.DecodeJWT(token)
if err != nil {}
render.IndexRender(uid,writer)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question