@@ -49,7 +49,7 @@ export function loggedInContext (context: AuthenticationContext): Promise<Authen
4949 authn . checkUser ( ) . then ( webId => {
5050 // Already logged in?
5151 if ( webId ) {
52- debug . log ( `logIn: Already logged in as ${ context . me } ` )
52+ debug . log ( `logIn: Already logged in as ${ webId } ` )
5353 return resolve ( context )
5454 }
5555 if ( ! context . div || ! context . dom ) {
@@ -448,9 +448,12 @@ function signInOrSignUpBox (
448448 signInPopUpButton . setAttribute ( 'style' , `${ signInButtonStyle } background-color: #eef;` )
449449
450450 authSession . onLogin ( ( ) => {
451- const sessionInfo = authSession . info
452- if ( sessionInfo && sessionInfo . isLoggedIn ) {
453- const webIdURI = sessionInfo . webId
451+ const me = authn . currentUser ( )
452+ // const sessionInfo = authSession.info
453+ // if (sessionInfo && sessionInfo.isLoggedIn) {
454+ if ( me ) {
455+ // const webIdURI = sessionInfo.webId
456+ const webIdURI = me . uri
454457 // setUserCallback(webIdURI)
455458 const divs = dom . getElementsByClassName ( magicClassName )
456459 debug . log ( `Logged in, ${ divs . length } panels to be serviced` )
@@ -498,27 +501,6 @@ function signInOrSignUpBox (
498501 return box
499502}
500503
501- // ======== WHAT IS THIS? ========
502- authSession . onLogout ( async ( ) => {
503- const issuer = window . localStorage . getItem ( 'loginIssuer' )
504- if ( issuer ) {
505- try {
506- const wellKnownUri = new URL ( issuer )
507- wellKnownUri . pathname = '/.well-known/openid-configuration'
508- const wellKnownResult = await fetch ( wellKnownUri . toString ( ) )
509- if ( wellKnownResult . status === 200 ) {
510- const openidConfiguration = await wellKnownResult . json ( )
511- if ( openidConfiguration && openidConfiguration . end_session_endpoint ) {
512- await fetch ( openidConfiguration . end_session_endpoint , { credentials : 'include' } )
513- }
514- }
515- } catch ( err ) {
516- // Do nothing
517- }
518- }
519- window . location . reload ( )
520- } )
521-
522504export function renderSignInPopup ( dom : HTMLDocument ) {
523505 /**
524506 * Issuer Menu
@@ -664,17 +646,18 @@ export function loginStatusBox (
664646 return
665647 }
666648
667- const uri = newidURI . uri || newidURI
668- me = sym ( uri )
649+ // const uri = newidURI.uri || newidURI
650+ // me = sym(uri)
651+ me = authn . saveUser ( newidURI )
669652 box . refresh ( )
670- if ( listener ) listener ( me . uri )
653+ if ( listener ) listener ( me ! . uri )
671654 }
672655
673656 function logoutButtonHandler ( _event ) {
674- // UI.preferences.set('me', '')
657+ const oldMe = me
675658 authSession . logout ( ) . then (
676659 function ( ) {
677- const message = `Your WebID was ${ me } . It has been forgotten.`
660+ const message = `Your WebID was ${ oldMe } . It has been forgotten.`
678661 me = null
679662 try {
680663 alert ( message )
@@ -711,12 +694,7 @@ export function loginStatusBox (
711694 }
712695
713696 box . refresh = function ( ) {
714- const sessionInfo = authSession . info
715- if ( sessionInfo && sessionInfo . webId && sessionInfo . isLoggedIn ) {
716- me = sym ( sessionInfo . webId )
717- } else {
718- me = null
719- }
697+ me = authn . currentUser ( )
720698 if ( ( me && box . me !== me . uri ) || ( ! me && box . me ) ) {
721699 widgets . clearElement ( box )
722700 if ( me ) {
@@ -727,20 +705,16 @@ export function loginStatusBox (
727705 }
728706 box . me = me ? me . uri : null
729707 }
708+ box . refresh ( )
730709
731710 function trackSession ( ) {
732- const sessionInfo = authSession . info
733- if ( sessionInfo && sessionInfo . webId && sessionInfo . isLoggedIn ) {
734- me = sym ( sessionInfo . webId )
735- } else {
736- me = null
737- }
711+ me = authn . currentUser ( )
738712 box . refresh ( )
739713 }
740714 trackSession ( )
715+
741716 authSession . onLogin ( trackSession )
742717 authSession . onLogout ( trackSession )
743-
744718 box . me = '99999' // Force refresh
745719 box . refresh ( )
746720 return box
0 commit comments