File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -253,7 +253,10 @@ class Autopass extends ReadyResource {
253253 if ( this . opened === false ) await this . ready ( )
254254 const readOnly = opts ?. readOnly ? true : false
255255 const existing = await this . base . view . findOne ( '@autopass/invite' , { } )
256- if ( existing ) {
256+
257+ if ( existing && existing . readOnly !== readOnly ) {
258+ await this . deleteInvite ( )
259+ } else if ( existing ) {
257260 if ( this . member ) await this . member . flushed ( )
258261 return z32 . encode ( existing . invite )
259262 }
Original file line number Diff line number Diff line change @@ -81,6 +81,26 @@ test('invites', async function (t) {
8181 } )
8282} )
8383
84+ test ( 'invite resets when createInvite type is different than previous' , async function ( t ) {
85+ t . plan ( 1 )
86+
87+ const tn = await testnet ( 10 , t )
88+
89+ const a = await create ( t , { bootstrap : tn . bootstrap } )
90+ t . teardown ( ( ) => {
91+ a . close ( )
92+ } )
93+
94+ const inv = await a . createInvite ( )
95+ const invReadOnly = await a . createInvite ( { readOnly : true } )
96+
97+ if ( inv !== invReadOnly ) {
98+ t . pass ( 'invite is reset ' )
99+ } else {
100+ t . fail ( )
101+ }
102+ } )
103+
84104test ( 'blind encryption' , async function ( t ) {
85105 t . plan ( 4 )
86106
You can’t perform that action at this time.
0 commit comments