23 lines
472 B
Go
23 lines
472 B
Go
package auth
|
|
|
|
import (
|
|
"auth_service/api/jwt"
|
|
"auth_service/model"
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
func VerifyToken(w http.ResponseWriter, req *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
var request model.Token
|
|
decoder := json.NewDecoder(req.Body)
|
|
decoder.Decode(&request)
|
|
_, e := jwt.VerifyJWT(request.Token, jwt.Defaultsecretkey)
|
|
if e != nil {
|
|
fmt.Fprintf(w, "{\"status\":403}")
|
|
return
|
|
}
|
|
fmt.Fprintf(w, "{\"status\":200}")
|
|
}
|