1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

feat(user):logout after change password EE-1590 (#6267)

* fix(user) logout after password change
This commit is contained in:
sunportainer 2022-01-21 08:33:43 +08:00 committed by GitHub
parent 58de8e175f
commit 661f0aad49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 53 additions and 11 deletions

View file

@ -121,6 +121,14 @@ func (service *Service) ParseAndVerifyToken(token string) (*portainer.TokenData,
if err == nil && parsedToken != nil {
if cl, ok := parsedToken.Claims.(*claims); ok && parsedToken.Valid {
user, err := service.dataStore.User().User(portainer.UserID(cl.UserID))
if err != nil {
return nil, errInvalidJWTToken
}
if user.TokenIssueAt > cl.StandardClaims.IssuedAt {
return nil, errInvalidJWTToken
}
return &portainer.TokenData{
ID: portainer.UserID(cl.UserID),
Username: cl.Username,
@ -162,6 +170,7 @@ func (service *Service) generateSignedToken(data *portainer.TokenData, expiresAt
Scope: scope,
StandardClaims: jwt.StandardClaims{
ExpiresAt: expiresAt,
IssuedAt: time.Now().Unix(),
},
}