FirebaseEmailPassword: Email & Password

Description Super class Active bindings Methods Note Examples

Description

Manage users using email and password.

Super class

firebase::Firebase -> FirebaseEmailPassword

Active bindings

created

Results of account creation

Methods

Public methods

Inherited methods

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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 March 31, 2020, 5:17 p.m.