JohnCoene/firebase

capturing error when authenticating using email password method

j-lim-sigma opened this issue · 4 comments

Hi, thanks for this useful package.

is there a way to capture the error message if user enters incorrect email or password? Thank you for your help.

You should be able to obtain this with the get_signed_in method, it returns a named list with a success variable; a boolean to indicate if the sign in was successful.

I am using the get_signed_in method to obtain user's information. However, it is only populated when sign in is successful. From the documentation in R, it is mentioned that the sign_in(email, password) method returns NULL if successful and the error otherwise. I am trying to capture this error, R returns this "Error in rule("Firebase Authentication") : could not find function "rule" "

Very interested in this too!

circling back to this because I also had the same issue -- seems like everything was returning NULL regardless of the success or failure. But after some digging it seems that a Shiny input variable called fireblaze_signed_up_user gets updated directly after the login attempt and holds the right info. So this code works for me in my server, where signin_account_email is just an action button:

f <- firebase::FirebaseEmailPassword$new()

observeEvent(
    input$signin_account_email, {
        f$sign_in(input$email, input$password)
    }
)

observeEvent(
    input$fireblaze_signed_up_user, {
        if (!is.null(input$fireblaze_signed_up_user$response$code)) {
            print('failed login')
        } else {
            print('successful login')
        }
    }
)