Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revises signInWithEmailAndPassword to return an either with the error or user credential #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Firebase/Auth.purs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Data.Nullable (Nullable, null, toMaybe)
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Aff (Aff, Error, attempt)
import Firebase.App (FirebaseApp)
import Unsafe.Coerce (unsafeCoerce)

Expand Down Expand Up @@ -99,10 +99,10 @@ foreign import signInAnonymouslyImp :: Fn1 Auth (Effect (Promise Unit))
signInAnonymously :: Auth -> Aff Unit
signInAnonymously auth = runFn1 signInAnonymouslyImp auth # toAffE

foreign import signInWithEmailAndPasswordImp :: Fn3 String String Auth (Effect (Promise Unit))
foreign import signInWithEmailAndPasswordImp :: Fn3 String String Auth (Effect (Promise UserCredential))

signInWithEmailAndPassword :: String -> String -> Auth -> Aff Unit
signInWithEmailAndPassword email password auth = runFn3 signInWithEmailAndPasswordImp email password auth # toAffE
signInWithEmailAndPassword :: String -> String -> Auth -> Aff (Either Error UserCredential)
signInWithEmailAndPassword email password auth = runFn3 signInWithEmailAndPasswordImp email password auth # toAffE # attempt

-- TODO: add Unsubscribe
foreign import onAuthStateChangedImp :: Fn2 (Nullable User -> Effect Unit) Auth (Effect (Effect Unit))
Expand Down