bahmutov / bahmutov/cypress-firebase-auth-example
How to set the object so that Auth thinks it has an user?
- Dominant language
- JavaScript
- Stars
- 5
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
I am calling Firebase auth endpoint, and am getting a good response, but how to save it in the IndexedDB?!
```js
const endpoint = `https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=${
config.apiKey
}`
cy.request({
method: 'POST',
url: endpoint,
form: true,
body: {
email,
password
}
})
.its('body')
// sure, use async / await functions for 3rd party code
// parcel bundler transpiles them nicely to promise-returning code
.then(async body => {
const db = await openDB('firebaseLocalStorageDb', 1, {
upgrade (db) {
db.createObjectStore('firebaseLocalStorage', {
keyPath: 'fbase_key',
autoIncrement: false
})
}
})
const fbase_key = `firebase:authUser:${config.apiKey}:[DEFAULT]`
const value = {
appName: '[DEFAULT]',
// createdAt: String(+new Date()),
displayName: body.displayName,
email: body.email,
emailVerified: false,
isAnonymous: false,
// lastLoginAt: String(+new Date()),
providerData: [
{
displayName: body.displayName,
email: body.email,
providerId: 'password',
uid: body.email
}
],
apiKey: config.apiKey,
authDomain: config.authDomain,
stsTokenManager: {
accessToken: body.idToken,
apiKey: config.apiKey
// expirationTime: +new Date() + 1000000
},
uid: body.localId
}
console.log(value)
await db.add('firebaseLocalStorage', {
fbase_key,
value
})
})
```
So far no luck, even as the entry looks like the right thing I see in the regular browser
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the issue's Cypress request and the IndexedDB setup for firebaseLocalStorageDb and firebaseLocalStorage. Compare the stored value with the Firebase authentication entry visible in the browser, then determine what change is needed for Auth to recognize the session. Done means the test is authenticated after the entry is written.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cypress, firebase, javascript
- Domain
- authentication, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100