Skip to content

Commit

Permalink
fix: cleanup persister
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed Aug 14, 2023
1 parent 1a1a489 commit 4f63d4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
5 changes: 4 additions & 1 deletion consent/strategy_logout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ func TestLogoutFlows(t *testing.T) {
checkAndAcceptLoginHandler(t, adminApi, subject, func(t *testing.T, res *hydra.OAuth2LoginRequest, err error) hydra.AcceptOAuth2LoginRequest {
require.NoError(t, err)
//res.Payload.SessionID
return hydra.AcceptOAuth2LoginRequest{Remember: pointerx.Ptr(true), IdentityProviderSessionId: pointerx.Ptr(kratos.FakeSessionID)}
return hydra.AcceptOAuth2LoginRequest{
Remember: pointerx.Ptr(true),
IdentityProviderSessionId: pointerx.Ptr(kratos.FakeSessionID),
}
}),
checkAndAcceptConsentHandler(t, adminApi, func(t *testing.T, res *hydra.OAuth2ConsentRequest, err error) hydra.AcceptOAuth2ConsentRequest {
require.NoError(t, err)
Expand Down
14 changes: 4 additions & 10 deletions persistence/sql/persister_consent.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,19 +422,13 @@ func (p *Persister) ConfirmLoginSession(ctx context.Context, session *flow.Login
return p.CreateWithNetwork(ctx, session)
}

var IdentityProviderSessionID string
if session != nil {
IdentityProviderSessionID = session.IdentityProviderSessionID.String()
}

// In some unit tests, we still confirm the login session without data from the cookie. We can remove this case
// once all tests are fixed.
n, err := p.Connection(ctx).Where("id = ? AND nid = ?", id, p.NetworkID(ctx)).UpdateQuery(&flow.LoginSession{
AuthenticatedAt: sqlxx.NullTime(authenticatedAt),
Subject: subject,
Remember: remember,
IdentityProviderSessionID: sqlxx.NullString(IdentityProviderSessionID),
}, "authenticated_at", "subject", "remember", "identity_provider_session_id")
AuthenticatedAt: sqlxx.NullTime(authenticatedAt),
Subject: subject,
Remember: remember,
}, "authenticated_at", "subject", "remember")
if err != nil {
return sqlcon.HandleError(err)
}
Expand Down

0 comments on commit 4f63d4f

Please sign in to comment.