Manage users using email and password.
Also signs in the user if successful.
firebase::Firebase -> firebase::FirebaseAuth -> FirebaseEmailPassword
createdResults of account creation
Inherited methods
firebase::Firebase$expose_app()firebase::FirebaseAuth$clear()firebase::FirebaseAuth$delete_user()firebase::FirebaseAuth$expose_auth()firebase::FirebaseAuth$get_access_token()firebase::FirebaseAuth$get_delete_user()firebase::FirebaseAuth$get_id_token()firebase::FirebaseAuth$get_sign_out()firebase::FirebaseAuth$get_signed_in()firebase::FirebaseAuth$get_signed_up()firebase::FirebaseAuth$is_signed_in()firebase::FirebaseAuth$print()firebase::FirebaseAuth$req_sign_in()firebase::FirebaseAuth$req_sign_out()firebase::FirebaseAuth$request_id_token()firebase::FirebaseAuth$set_language_code()firebase::FirebaseAuth$sign_out()
new()FirebaseEmailPassword$new(
persistence = c("session", "local", "memory"),
config_path = "firebase.rds",
language_code = NULL,
session = shiny::getDefaultReactiveDomain()
)persistenceHow the auth should persit: none, the user has to sign in at every visit,
session will only persist in current tab, local persist even when window is closed.
config_pathPath to the configuration file as created by firebase_config.
language_codeSets the language to use for the UI.
Supported languages are listed here.
Set to browser to use the default browser language of the user.
sessionA valid shiny session.
re_authenticate()Re-authenticate the user.
Some security-sensitive actions—such as deleting an account, setting a primary email address, and changing a password—require that the user has recently signed in. If you perform one of these actions, and the user signed in too long ago, the action fails with an error.
library(shiny)
library(firebase)
# modals
register <- modalDialog(
title = "Register",
textInput("email_create", "Your email"),
passwordInput("password_create", "Your password"),
footer = actionButton("create", "Register")
)
sign_in <- modalDialog(
title = "Sign in",
textInput("email_signin", "Your email"),
passwordInput("password_signin", "Your password"),
footer = actionButton("signin", "Sign in")
)
ui <- fluidPage(
useFirebase(), # import dependencies
actionButton("register_modal", "Register"),
actionButton("signin_modal", "Signin"),
plotOutput("plot")
)
server <- function(input, output){
f <- FirebaseEmailPassword$new()
# open modals
observeEvent(input$register_modal, {
showModal(register)
})
observeEvent(input$signin_modal, {
showModal(sign_in)
})
# create the user
observeEvent(input$create, {
f$create(input$email_create, input$password_create)
})
# check if creation sucessful
observeEvent(f$get_created(), {
created <- f$get_created()
if(created$success){
removeModal()
showNotification("Account created!", type = "message")
} else {
showNotification("Error!", type = "error")
}
# print results to the console
print(created)
})
observeEvent(input$signin, {
removeModal()
f$sign_in(input$email_signin, input$password_signin)
})
output$plot <- renderPlot({
f$req_sign_in()
plot(cars)
})
}
if (FALSE) shinyApp(ui, server)