@@ -2,7 +2,6 @@ package webapp
2
2
3
3
import (
4
4
"context"
5
- "errors"
6
5
"fmt"
7
6
"net/http"
8
7
@@ -315,19 +314,16 @@ func (c *Controller) rewindSessionHistory(session *webapp.Session) error {
315
314
return nil
316
315
}
317
316
318
- func (c * Controller ) GetWebappSession (ctx context.Context ) (* webapp.Session , error ) {
317
+ func (c * Controller ) InteractionSession (ctx context.Context ) (* webapp.Session , error ) {
319
318
s := webapp .GetSession (ctx )
320
- if s == nil {
319
+ if s == nil || s . IsCompleted {
321
320
return nil , webapp .ErrSessionNotFound
322
321
}
323
- if s .IsCompleted {
324
- return nil , webapp .ErrSessionCompleted
325
- }
326
322
return s , nil
327
323
}
328
324
329
325
func (c * Controller ) InteractionGet (ctx context.Context ) (* interaction.Graph , error ) {
330
- s , err := c .GetWebappSession (ctx )
326
+ s , err := c .InteractionSession (ctx )
331
327
if err != nil {
332
328
return nil , err
333
329
}
@@ -348,7 +344,7 @@ func (c *Controller) InteractionGetWithSession(ctx context.Context, s *webapp.Se
348
344
}
349
345
350
346
func (c * Controller ) InteractionPost (ctx context.Context , inputFn func () (interface {}, error )) (* webapp.Result , error ) {
351
- s , err := c .GetWebappSession (ctx )
347
+ s , err := c .InteractionSession (ctx )
352
348
if err != nil {
353
349
return nil , err
354
350
}
@@ -381,13 +377,9 @@ func (c *Controller) InteractionOAuthCallback(ctx context.Context, oauthInput In
381
377
}
382
378
383
379
func (c * Controller ) getSettingsActionWebSession (ctx context.Context , r * http.Request ) (* webapp.Session , error ) {
384
- webappSession , err := c .GetWebappSession (ctx )
385
- if err != nil {
386
- // No session means it is not in settings action
387
- if errors .Is (err , webapp .ErrSessionNotFound ) {
388
- return nil , nil
389
- }
390
- return nil , err
380
+ webappSession := webapp .GetSession (ctx )
381
+ if webappSession == nil {
382
+ return nil , nil
391
383
}
392
384
if webappSession .SettingsActionID == "" {
393
385
// This session is not for a settings action, ignore it
@@ -401,6 +393,9 @@ func (c *Controller) getSettingsActionWebSession(ctx context.Context, r *http.Re
401
393
// This session is not for the current settings action, ignore it
402
394
return nil , nil
403
395
}
396
+ if webappSession .IsCompleted {
397
+ return nil , webapp .ErrSessionCompleted
398
+ }
404
399
return webappSession , nil
405
400
}
406
401
0 commit comments