Do you want to request a feature or report a bug?
I would like to suggest a feature that is to add the isSignInWithEmailLink authentication method.
I may try find some time to figure it out and make a PR it back. I havent dug deep yet into it, but its a rad feature.
@leighs-hammer Great suggestion! For now you should be able to access it through props.firebase.auth(), but it won't do automatic dispatches or profile handling.
@prescottprue I gave it a whirl, using props.firebase.auth().isSignInWithEmailLink and it works fine!!!
Its verbose and not elegant, but simply firing firebase.login(firebase.auth().currentUser) within the promise once I had checked for a valid response when some one is entering off a link, seems to dispatch all the profile niceties. :)
It might be worth noting that in the code that @leighs-hammer provided, firebase.login is from react-redux-firebase and firebase.auth is from firebase/app.
i.e. firebase.login(firebase.auth().currentUser) -> props.firebase.login(firebase.auth().currentUser)
I guess it's noted in his comment on re-read, but it's probably worth being explicit.
@dfee It is also available on props.firebase.auth() so:
firebase.login(firebase.auth().currentUser)
// or
props.firebase.login(props.firebase.auth().currentUser)
@prescottprue it doesn't seem anything really has a type in this package, but which firebase is which?
for instance the firebase of firebase/app doesn't have a login method. Also, it appears the firebase that is part of the store also doesn't have a login method. I've spent a few minutes today trying to figure out which is which is which.
Instances of firebase in the docs are talking about store.firebase which is often passed through react context then passed as a prop (props.firebase). This contains methods, such as login, which dispatch actions and call internal Firebase methods from the JS SDK.
The "firebase" from firebase/app is the default Firebase JS SDK. As you noted, it does not contain methods from the docs of react-redux-firebase (such as login). Any info about the it can be found in the Firebase docs.
This has been mentioned as unclear in the past, so there has been some thought about a better way to name this "instance". As for typing: there is basic typing included for top level methods for now and there has also been some research into moving over to typescript. Always open PRs if you get a chance.
So is the firebase that comes from withFirebase an enhanced version (a superset object) of the firebase from firebase/app? They both seem to have the auth() function.
The reason I'm asking is that I've broken my app, and I'm using the sendSignInLinkToEmail and upon calling: props.firebase.login(props.firebase.auth().currentUser) I get the following error:
message: signInAndRetrieveDataWithEmailAndPassword failed: Second argument "password" must be a valid string.
code: auth/argument-error
I can't tell why signInAndRetrieveDataWithEmailAndPassword is being called though; it's not in my code.
It looks like it's coming from here: https://github.com/prescottprue/react-redux-firebase/blob/44fa39d3c43b029891c317ef54804ee345d310fb/src/utils/auth.js#L120-L121
Was it not actually working for me before and this library doesn't support email link signin?
@dfee The line you are pointing to does not invoke signInAndRetrieveDataWithEmailAndPassword, it just checks for it's existence. If it exists, then it is used as as the default when login in. It looks it is coming from the fact that you are attempting to log in by passing the existing current user (props.firebase.auth().currentUser). Not sure what the intention is with that, but there shouldn't need to be login if there is already a currentUser (i.e. firebase is authed).
There is not currently a top level method that calls dispatch for sendSignLinkToEmail, but you should just be able to call it directly through firebase.auth().sendSignLinkToEmail. It doesn't seem like there would need to be anything dispatched to state for that, but open to suggestions if you think of something. That said, the original as of exposing isSignInWithEmailLink does seem like it would be useful as it makes sense to dispatch state updates for that (both auth and profile).
Realized that it didn't make much sense to write the result of a boolean like this into state when trying to implement. Open to ideas, but going to close for now. Thanks for posting
Most helpful comment
@prescottprue I gave it a whirl, using props.firebase.auth().isSignInWithEmailLink and it works fine!!!
Its verbose and not elegant, but simply firing
firebase.login(firebase.auth().currentUser)within the promise once I had checked for a valid response when some one is entering off a link, seems to dispatch all the profile niceties. :)