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
- title
Login page title.
- label
Login confirm button label.
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.
Note
There is an input associated with the login status, namely input$login
.
It is linked to an action button, input$submit
, which is 0 when the application starts. As soon
as the button is pressed, its value is incremented which may be used to call
updateF7Login. input$user
and input$password
contains values passed
by the user in these respective fields and can be forwarded to updateF7Login.
input$cancel
is increment whenever the login is closed when cancellable. You can access
the value and trigger other actions on the server, as shown in f7LoginServer.
Examples
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