Sign in

You can always access the signed in user with the get_signed_in method. This returns a list of length 2:

  1. signed_in: boolean
  2. user: a list (NULL if signed out)

The user object returned looks like.

#> $signed_in
#> [1] TRUE
#> 
#> $user
#> $user$uid
#> [1] "XXxxX"
#> 
#> $user$displayName
#> [1] "John"
#> 
#> $user$photoURL
#> [1] "https://lh3.googleusercontent.com/a-/XXxxX"
#> 
#> $user$email
#> [1] "myemail@gmail.com"
#> 
#> $user$emailVerified
#> [1] TRUE
#> 
#> $user$phoneNumber
#> NULL
#> 
#> $user$isAnonymous
#> [1] FALSE
#> 
#> $user$tenantId
#> NULL
#> 
#> $user$providerData
#> $user$providerData[[1]]
#> $user$providerData[[1]]$uid
#> [1] "XXxxX"
#> 
#> $user$providerData[[1]]$displayName
#> [1] "John Coene"
#> 
#> $user$providerData[[1]]$photoURL
#> [1] "https://lh3.googleusercontent.com/a-/XXxxX"
#> 
#> $user$providerData[[1]]$email
#> [1] "jcoenep@gmail.com"
#> 
#> $user$providerData[[1]]$phoneNumber
#> NULL
#> 
#> $user$providerData[[1]]$providerId
#> [1] "google.com"
#> 
#> 
#> 
#> $user$apiKey
#> [1] "XXxxX"
#> 
#> $user$appName
#> [1] "[DEFAULT]"
#> 
#> $user$authDomain
#> [1] "my-package.firebaseapp.com"
#> 
#> $user$stsTokenManager
#> $user$stsTokenManager$apiKey
#> [1] "XXxxX"
#> 
#> $user$stsTokenManager$refreshToken
#> [1] "XXxxX"
#> 
#> $user$stsTokenManager$accessToken
#> [1] "XXxxX"
#> 
#> $user$stsTokenManager$expirationTime
#> [1] 1.584898e+12
#> 
#> 
#> $user$redirectEventId
#> NULL
#> 
#> $user$lastLoginAt
#> [1] "1584894612585"
#> 
#> $user$createdAt
#> [1] "1584894612585"
#> 
#> $user$multiFactor
#> $user$multiFactor$enrolledFactors
#> list()

Note this is technically like a Shiny input and behaves as such. Therefore the snippet below will work. Note that it will be triggered on load.

# initialise
f <- FireblazeUI$new()$launch()

observeEvent(f$get_signed_in(), {
  # do somethind
})

However one should probably only rely on the get_signed_in to retrieve information about the logged in user, the methods is_signed_in and req_sign_in should be used in observers instead. The first returns TRUE if the user is signed in. The second, req_sign_in is a convenience method which essentially does req(f$is_signed_in) which allows “marking” outputs and observers that require sign in.

Sign out

A single method is shared across all authentication methods, simply call sign_out method.

Re-auth

Two sensitive operations, deleting an account, and changing a password (only application to email & password method), might require that you re-authenticate the user. These operations being dangerous they will fail if the user has been signed in for a long time and you will have to first re-authenticate them using their current password.

f <- FirebaseEmailPassword$new()

# upon clicking a button
observeEvent(input$reAuth, {
  # pass the freshly entered user password
  f$re_authenticate(input$reAuthPassword)
})

# check if reauth successful
observeEvent(input$get_re_authenticated(), {
  reauth <- input$get_re_authenticated()

  # TRUE if successful
  print(reauth$success)
})

Delete

Simply use the delete_user method and observe the result with the get_delete_user method. This will likely required re-authentication.

Email & Password

Signing in users with email and password may require some work, at times, to manage them. You might want to send them an email verification link, allow them to change or reset their password.

You can freely send a verification email with the send_verification_email and receive the response to it with get_verification_email.