You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my app I provide a login screen where the user enters a password to get access to the applications data. Chances are good that the user types his password wrong and tries to authenticate with it. If I try to enter a random wrong password, RxDB gives me an error like this:
Error: RxError:
RxDocument.prepare(): another instance on this adapter has a different password
Given parameters: {
passwordHash:"3676c0a1..."
existingPasswordHash:"5b3e907a3b9a95c92983a3889a5ab727"}
at new RxError (blob:http://localhost:8081/3a48a823-f689-4dfa-a9e5-9bad378bd400:81975:129)
at Object.newRxError (blob:http://localhost:8081/3a48a823-f689-4dfa-a9e5-9bad378bd400:82052:16)
at RxDatabase._callee2$ (blob:http://localhost:8081/3a48a823-f689-4dfa-a9e5-9bad378bd400:70807:64)
at tryCatch (blob:http://localhost:8081/3a48a823-f689-4dfa-a9e5-9bad378bd400:16635:19)
...
This behavior is totally fine. The interesting part comes when I try to enter the correct password, right after the previous error occurred:
Error: RxError:
RxDatabase.create(): A RxDatabase with the same name and adapter already exists.
Make sure to use this combination only once or set ignoreDuplicate to true if you do this intentional
Given parameters: {
name:"safeword"
adapter:"asyncstorage"
link:"https://pubkey.github.io/rxdb/rx-database.html#ignoreduplicate"}
at new RxError (blob:http://localhost:8081/3a48a823-f689-4dfa-a9e5-9bad378bd400:81975:129)
at Object.newRxError (blob:http://localhost:8081/3a48a823-f689-4dfa-a9e5-9bad378bd400:82052:16)
at _isNameAdapterUsed (blob:http://localhost:8081/3a48a823-f689-4dfa-a9e5-9bad378bd400:71352:40)
at Object._callee8$ (blob:http://localhost:8081/3a48a823-f689-4dfa-a9e5-9bad378bd400:70510:51)
at tryCatch (blob:http://localhost:8081/3a48a823-f689-4dfa-a9e5-9bad378bd400:16635:19)
...
The only explanation I could think of for this error is, that an other instance of the database with the wrong password was created after the first error. Sadly the examples show only how the database is handled with a predefined password.
What helps to be able to login again is to restart the app. This leads me to the question: Is this behavior expected? Is there a way I can recover from a wrong password and afterwards open the existing database with the correct password?
This behavior occurs in React Native as well as in Electron.
Adapter: IndexedDB with Electron, AsyncStorage with React Native
Stack: Babel, React 16.5.2, RxDB 7.7.1
Code
The following function is used to connect to the database with the password provided by the user. The variable db is still empty when the error occurs as RxDB.create(rx) fails immediately.
db=nulladapter=``load=async(password)=>{// Return existing database if already set upif(this.db!==null)returnthis.db.collection({name: 'safeword',
schema
}).catch(err=>this.db.safeword)if(globals.PLATFORM==='desktop'){RxDB.plugin(require('pouchdb-adapter-idb'))this.adapter='idb'}elseif(globals.PLATFORM==='mobile'){RxDB.plugin(require('pouchdb-adapter-asyncstorage').default)this.adapter='asyncstorage'}constrx={name: 'safeword',adapter: this.adapter,multiInstance: false,
password
}returnRxDB.create(rx).then(asyncdb=>{this.db=dbsafeword=awaitthis.db.collection({name: 'safeword',
schema
}).catch(err=>this.db.safeword)returnthis.db.safeword})}
The text was updated successfully, but these errors were encountered:
Case
Question
Issue
In my app I provide a login screen where the user enters a password to get access to the applications data. Chances are good that the user types his password wrong and tries to authenticate with it. If I try to enter a random wrong password, RxDB gives me an error like this:
This behavior is totally fine. The interesting part comes when I try to enter the correct password, right after the previous error occurred:
The only explanation I could think of for this error is, that an other instance of the database with the wrong password was created after the first error. Sadly the examples show only how the database is handled with a predefined password.
What helps to be able to login again is to restart the app. This leads me to the question: Is this behavior expected? Is there a way I can recover from a wrong password and afterwards open the existing database with the correct password?
This behavior occurs in React Native as well as in Electron.
Info
Code
The following function is used to connect to the database with the password provided by the user. The variable
db
is still empty when the error occurs asRxDB.create(rx)
fails immediately.The text was updated successfully, but these errors were encountered: