This repository was archived by the owner on Aug 9, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 1- const localstorage = require ( 'store' )
21const IPFS = require ( 'ipfs' )
32const multiaddr = require ( 'multiaddr' )
43const { createLink, validateLink } = require ( '3id-blockchain-utils' )
@@ -48,6 +47,7 @@ class Box extends BoxApi {
4847 super ( )
4948 this . _provider = provider
5049 this . _ipfs = ipfs
50+ this . _opts = opts
5151 this . _serverUrl = opts . addressServer || ADDRESS_SERVER_URL
5252 /**
5353 * @property {KeyValueStore } public access the profile store of the users 3Box
@@ -560,10 +560,21 @@ class Box extends BoxApi {
560560 */
561561 async logout ( ) {
562562 if ( ! this . _3id ) throw new Error ( 'logout: auth required' )
563+
563564 await this . close ( )
564565 this . _3id . logout ( )
565- const address = await this . _3id . getAddress ( )
566- localstorage . remove ( 'linkConsent_' + address )
566+
567+ delete this . _3idEthAddress
568+ delete this . replicator
569+ delete this . _3id
570+
571+ this . public = null
572+ this . private = null
573+ this . spaces = { }
574+ this . syncDone = null
575+ this . hasPublishedLink = { }
576+
577+ await this . _init ( this . _opts )
567578 }
568579
569580 /**
@@ -573,6 +584,7 @@ class Box extends BoxApi {
573584 * @return {Boolean } true if the user is logged in
574585 */
575586 static isLoggedIn ( address ) {
587+ console . warn ( 'Box.isLoggedIn: function no longer supported, simply call auth and it will not prompt user again if they have already authenticated' )
576588 return ThreeId . isLoggedIn ( address )
577589 }
578590
Original file line number Diff line number Diff line change @@ -283,6 +283,8 @@ class ThreeId {
283283 }
284284
285285 logout ( ) {
286+ this . _rootDID = null
287+ this . _subDIDs = { }
286288 localstorage . remove ( STORAGE_KEY + this . managementAddress )
287289 this . stopUpdatePolling ( )
288290 }
Original file line number Diff line number Diff line change @@ -435,15 +435,13 @@ describe('3Box', () => {
435435 const box = await Box . openBox ( '0x12345' , 'web3prov' , boxOpts )
436436 await box . logout ( )
437437 expect ( mocked3id . logoutFn ) . toHaveBeenCalledTimes ( 1 )
438- return box . close ( )
439438 } )
440439
441440 it ( 'should be logged out' , async ( ) => {
442441 const box = await Box . openBox ( '0x12345' , 'web3prov' , boxOpts )
443442 await box . logout ( )
444443 const isLoggedIn = Box . isLoggedIn ( '0xabcde' )
445444 expect ( isLoggedIn ) . toEqual ( false )
446- return box . close ( )
447445 } )
448446
449447 it ( 'should verify profiles correctly' , async ( ) => {
You can’t perform that action at this time.
0 commit comments