Skip to content

Commit 8ba97b6

Browse files
committed
Create a new session if current session is completed if allowed
1 parent 04589be commit 8ba97b6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pkg/auth/handler/webapp/authflow_controller.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (c *AuthflowController) HandleStartOfFlow(
202202
handleWithScreen(screen)
203203
}
204204

205-
func (c *AuthflowController) isExpectedWebSessionError(err error) bool {
205+
func (c *AuthflowController) isWebSessionNotFoundOrCompletedError(err error) bool {
206206
return apierrors.IsKind(err, webapp.WebUIInvalidSession) || apierrors.IsKind(err, webapp.WebUISessionCompleted)
207207
}
208208

@@ -211,7 +211,7 @@ func (c *AuthflowController) HandleOAuthCallback(ctx context.Context, w http.Res
211211

212212
s, err := c.Sessions.Get(ctx, state.WebSessionID)
213213
if err != nil {
214-
if !c.isExpectedWebSessionError(err) {
214+
if !c.isWebSessionNotFoundOrCompletedError(err) {
215215
c.Logger.WithError(err).Errorf("failed to get web session")
216216
}
217217
c.renderError(ctx, w, r, err)
@@ -313,7 +313,7 @@ func (c *AuthflowController) HandleStep(ctx context.Context, w http.ResponseWrit
313313

314314
s, err := c.getWebSession(ctx)
315315
if err != nil {
316-
if !c.isExpectedWebSessionError(err) {
316+
if !c.isWebSessionNotFoundOrCompletedError(err) {
317317
c.Logger.WithError(err).Errorf("failed to get web session")
318318
}
319319
c.renderError(ctx, w, r, err)
@@ -345,7 +345,7 @@ func (c *AuthflowController) HandleWithoutFlow(ctx context.Context, w http.Respo
345345
var session *webapp.Session
346346
s, err := c.getWebSession(ctx)
347347
if err != nil {
348-
if !c.isExpectedWebSessionError(err) {
348+
if !c.isWebSessionNotFoundOrCompletedError(err) {
349349
c.Logger.WithError(err).Errorf("failed to get web session")
350350
}
351351
} else {
@@ -384,7 +384,8 @@ func (c *AuthflowController) getOrCreateWebSession(ctx context.Context, w http.R
384384
if err == nil && s != nil {
385385
return s, nil
386386
}
387-
if !errors.Is(err, webapp.ErrSessionNotFound) {
387+
388+
if !c.isWebSessionNotFoundOrCompletedError(err) {
388389
return nil, err
389390
}
390391

0 commit comments

Comments
 (0)