File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed
Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -52,31 +52,26 @@ export default class SolidAuthClient extends EventEmitter {
5252 async currentSession (
5353 storage : AsyncStorage = defaultStorage ( )
5454 ) : Promise < ?Session > {
55- // Try to obtain a stored session
56- let session = await getSession ( storage )
55+ // Try to obtain a stored or pending session
56+ let session = this . _pendingSession || ( await getSession ( storage ) )
5757
58- // Try to create a new session
58+ // If none found, attempt to create a new session
5959 if ( ! session ) {
60- // Return if session creation is already pending
61- if ( this . _pendingSession ) {
62- return this . _pendingSession
63- }
64-
65- // Create a new OIDC session
60+ // Try to create a new OIDC session from stored tokens
6661 try {
6762 this . _pendingSession = WebIdOidc . currentSession ( storage )
6863 session = await this . _pendingSession
6964 } catch ( err ) {
7065 console . error ( err )
7166 }
72- delete this . _pendingSession
7367
74- // Save the session and emit session events
68+ // Save the new session and emit session events
7569 if ( session ) {
7670 await saveSession ( storage ) ( session )
7771 this . emit ( 'login' , session )
7872 this . emit ( 'session' , session )
7973 }
74+ delete this . _pendingSession
8075 }
8176 return session
8277 }
You can’t perform that action at this time.
0 commit comments