Learn R Programming

shinyMobile (version 2.0.1)

f7Login: Framework7 login screen

Description

Provide a UI template for authentication

f7LoginServer is demonstration module to test the f7Login page. We do not recommend using it in production, since there is absolutely no security over the passed credentials. On the JS side, the login is closed as soon as a user and password are provided but no validity checks are made.

updateF7Login toggles a login page.

Usage

f7Login(
  ...,
  id,
  title,
  label = "Sign In",
  footer = NULL,
  startOpen = TRUE,
  cancellable = FALSE
)

f7LoginServer(id, ignoreInit = FALSE, trigger = NULL)

updateF7Login( id = deprecated(), user = NULL, password = NULL, cancel = FALSE, session = shiny::getDefaultReactiveDomain() )

Arguments

...

Slot for inputs like password, text, ...

id

[Deprecated].

title

Login page title.

label

Login confirm button label.

footer

Optional footer.

startOpen

Whether to open the login page at start. Default to TRUE. There are some cases where it is interesting to set up to FALSE, for instance when you want to have authentication only in a specific tab of your app (See example 2).

cancellable

Whether to show a cancel button to close the login modal. Default to FALSE.

ignoreInit

If TRUE, then, when this observeEvent is first created/initialized, ignore the handlerExpr (the second argument), whether it is otherwise supposed to run or not. The default is FALSE.

trigger

Reactive trigger to toggle the login page state. Useful, when one wants to set up local authentication (for a specific section). See example 2.

user

Value of the user input.

password

Value of the password input.

cancel

Whether to close the login. Default to FALSE.

session

Shiny session object.

Examples

Run this code
library(shiny)
library(shinyMobile)

app <- shinyApp(
  ui = f7Page(
    title = "Login module",
    f7SingleLayout(
      navbar = f7Navbar(
        title = "Login Example"
      ),
      toolbar = f7Toolbar(
        position = "bottom",
        f7Link(label = "Link 1", href = "https://www.google.com"),
        f7Link(label = "Link 2", href = "https://www.google.com")
      ),
      f7Login(id = "login", title = "Welcome", cancellable = TRUE),
      # main content
      f7BlockTitle(
        title = HTML(paste("Welcome", textOutput("user"))),
        size = "large"
      )
    )
  ),
  server = function(input, output, session) {
    loginData <- f7LoginServer(id = "login")

    exportTestValues(
      status = loginData$status(),
      user = loginData$user(),
      password = loginData$password(),
      authenticated = loginData$authenticated(),
      cancelled = loginData$cancelled()
    )

    output$user <- renderText({
      req(loginData$user)
      loginData$user()
    })
  }
)

if (interactive() || identical(Sys.getenv("TESTTHAT"), "true")) app

Run the code above in your browser using DataLab