fix: resetting the password or cancelling a registration ends existing sessions: a token issued before the change is refused
This commit is contained in:
1 parent
81c4b62175
commit
f3ec3d2fa2
15 files changed
+844
-13
No files matched your search
@@ -24,3 +24,22 @@ func UserId(r *http.Request) (uint32, bool) {
|
||||
|
||||
return uint32(userIdFloat), true
|
||||
}
|
||||
|
||||
func TokenVersion(r *http.Request) (uint32, bool) {
|
||||
_, claims, err := jwtauth.FromContext(r.Context())
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
rawTokenVersion, ok := claims["token_version"]
|
||||
if !ok {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
tokenVersionFloat, ok := rawTokenVersion.(float64)
|
||||
if !ok {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return uint32(tokenVersionFloat), true
|
||||
}
|
||||
Reference in new issue
Block a user