FirebaseEmailPassword: Email & Password

FirebaseEmailPasswordR Documentation

Email & Password

Description

Manage users using email and password.

Value

An object of class FirebaseEmailPassword.

Super classes

firebase::Firebase -> firebase::FirebaseAuth -> FirebaseEmailPassword

Active bindings

created

Results of account creation

Methods

Public methods

Inherited methods

Method new()

Usage
FirebaseEmailPassword$new(
  persistence = c("session", "local", "memory"),
  config_path = "firebase.rds",
  language_code = NULL,
  session = shiny::getDefaultReactiveDomain()
)
Arguments
persistence

How 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_path

Path to the configuration file as created by firebase_config.

language_code

Sets the language to use for the UI. Supported languages are listed here. Set to browser to use the default browser language of the user.

session

A valid shiny session.

Details

Initialiases Firebase Email Password

Initialises the Firebase application client-side.


Method create()

Usage
FirebaseEmailPassword$create(email, password)
Arguments
email, password

Credentials as entered by the user.

Details

Create an account

Returns

self


Method sign_in()

Usage
FirebaseEmailPassword$sign_in(email, password)
Arguments
email, password

Credentials as entered by the user.

Details

Sign in with email

Returns

NULL if successful, the error otherwise.


Method get_created()

Usage
FirebaseEmailPassword$get_created()
Details

Get account creation results

Returns

A list of length 2 containing success a boolean indicating wherther creation was successful and response containing the result of account creation or the error if failed.


Method reset_password()

Usage
FirebaseEmailPassword$reset_password(email = NULL)
Arguments
email

Email to send reset link to, if missing looks for current logged in user's email.

Details

Reset user password

Returns

self


Method get_reset()

Usage
FirebaseEmailPassword$get_reset()
Details

Get whether password reset email was successfully sent

Returns

A list of length 2 containing success a boolean indicating whether email reset was successful and response containing successful or the error.


Method send_verification_email()

Usage
FirebaseEmailPassword$send_verification_email()
Details

Send the user a verification email

Returns

self


Method get_verification_email()

Usage
FirebaseEmailPassword$get_verification_email()
Details

Get result of verification email sending procedure

Returns

A list of length 2 containing success a boolean indicating whether email verification was successfully sent and response containing successful or the error.


Method set_password()

Usage
FirebaseEmailPassword$set_password(password)
Arguments
password

The authenticated user password, the user should be prompted to enter it.

Details

Set user password

Useful to provide ability to change password.

Returns

self


Method get_password()

Usage
FirebaseEmailPassword$get_password()
Details

Get response from set_password

Returns

A list of length 2 containing success a boolean indicating whether setting password was successfully set and response containing successful as string or the error.


Method re_authenticate()

Usage
FirebaseEmailPassword$re_authenticate(password)
Arguments
password

The authenticated user password, the user should be prompted to enter it.

Details

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.

Returns

self


Method get_re_authenticated()

Usage
FirebaseEmailPassword$get_re_authenticated()
Details

Get response from re_authenticate

Returns

A list of length 2 containing success a boolean indicating whether re-authentication was successful and response containing successful as string or the error.


Method clone()

The objects of this class are cloneable with this method.

Usage
FirebaseEmailPassword$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Note

Also signs in the user if successful.

Examples

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)
  })

}

## Not run: shinyApp(ui, server)


firebase documentation built on July 9, 2023, 7:07 p.m.