@@ -34,9 +34,10 @@ function signout (req, res, next) {
34
34
if ( idToken instanceof Error ) { return next ( idToken ) }
35
35
clientId = idToken . payload . aud
36
36
}
37
- if ( idToken && postLogoutUri ) {
37
+ authenticator . logout ( req )
38
+ if ( clientId && postLogoutUri ) {
38
39
// Verify the post-signout uri (must have been registered for this client)
39
- Client . get ( clientId , function ( err , client ) {
40
+ return Client . get ( clientId , function ( err , client ) {
40
41
if ( err ) { return next ( err ) }
41
42
var isValidUri = false
42
43
if ( client ) {
@@ -49,22 +50,24 @@ function signout (req, res, next) {
49
50
postLogoutUri += '?state=' + state
50
51
}
51
52
// sign out and redirect
52
- authenticator . logout ( req )
53
- res . redirect ( 303 , postLogoutUri )
54
- return
53
+ return res . redirect ( 303 , postLogoutUri )
55
54
}
56
55
// Otherwise, fall through to default case below
56
+ return emptyresponse ( res )
57
57
} )
58
58
}
59
59
// Handle all the other cases - no postLogoutUri specified, or the client is
60
60
// unknown, or the given postLogoutUri has not been registered previously.
61
61
// Do not redirect, simply sign out
62
- authenticator . logout ( req )
62
+ return emptyresponse ( res )
63
+ }
64
+
65
+ function emptyresponse ( res ) {
63
66
res . set ( {
64
67
'Cache-Control' : 'no-store' ,
65
68
'Pragma' : 'no-cache'
66
69
} )
67
- res . sendStatus ( 204 )
70
+ return res . sendStatus ( 204 )
68
71
}
69
72
70
73
/**
0 commit comments