Fix active session must not be return if expired
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -300,6 +300,14 @@ func (s SessionService) GetActiveSessionForMembership(ctx context.Context, rootS
|
||||
return fmt.Errorf("cannot load child session: %w", err)
|
||||
}
|
||||
|
||||
if childSession.ExpireReason != nil {
|
||||
return NewSessionExpiredError(childSession.ID)
|
||||
}
|
||||
|
||||
if time.Now().After(childSession.ExpiredAt) {
|
||||
return NewSessionExpiredError(childSession.ID)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
@@ -144,9 +144,12 @@ func (r *membershipResolver) ActiveSession(ctx context.Context, obj *types.Membe
|
||||
|
||||
session, err := r.iam.SessionService.GetActiveSessionForMembership(ctx, rootSession.UserID, obj.ID)
|
||||
if err != nil {
|
||||
var errSessionNotFound *iam.ErrSessionNotFound
|
||||
var (
|
||||
errSessionNotFound *iam.ErrSessionNotFound
|
||||
errSessionExpired *iam.ErrSessionExpired
|
||||
)
|
||||
|
||||
if errors.As(err, &errSessionNotFound) {
|
||||
if errors.As(err, &errSessionNotFound) || errors.As(err, &errSessionExpired) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user