From 64f988c3c07fd880c19c57e871b8272fbaa342dc Mon Sep 17 00:00:00 2001 From: PaulC91 Date: Mon, 4 Mar 2024 17:16:15 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20PaulC91/?= =?UTF-8?q?shinyauthr@1eea807a5d1ddfd5f67505110029c5b9389cc3f6=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 404.html | 2 +- LICENSE-text.html | 2 +- LICENSE.html | 3 +- authors.html | 6 +- index.html | 335 ++++++++++++++++++------------------ news/index.html | 18 +- pkgdown.yml | 6 +- reference/index.html | 2 +- reference/login.html | 55 ++++-- reference/loginServer.html | 144 +++++++++------- reference/loginUI.html | 135 ++++++++------- reference/logout.html | 32 ++-- reference/logoutServer.html | 104 +++++------ reference/logoutUI.html | 117 +++++++------ reference/runExample.html | 21 ++- 15 files changed, 550 insertions(+), 432 deletions(-) diff --git a/404.html b/404.html index 7ea6beb..b5b6587 100644 --- a/404.html +++ b/404.html @@ -94,7 +94,7 @@

Page not found (404)

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/LICENSE-text.html b/LICENSE-text.html index 3302bc2..f9593d7 100644 --- a/LICENSE-text.html +++ b/LICENSE-text.html @@ -71,7 +71,7 @@

License

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/LICENSE.html b/LICENSE.html index c8a9861..2ad518f 100644 --- a/LICENSE.html +++ b/LICENSE.html @@ -53,6 +53,7 @@

MIT License

+

Copyright (c) 2021 shinyauthr authors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

@@ -74,7 +75,7 @@

MIT License

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/authors.html b/authors.html index e2209f9..9967ca6 100644 --- a/authors.html +++ b/authors.html @@ -71,14 +71,14 @@

Citation

-

Campbell P (2022). +

Campbell P (2024). shinyauthr: 'Shiny' Authentication Modules. R package version 1.0.0.9000, https://github.com/paulc91/shinyauthr.

@Manual{,
   title = {shinyauthr: 'Shiny' Authentication Modules},
   author = {Paul Campbell},
-  year = {2022},
+  year = {2024},
   note = {R package version 1.0.0.9000},
   url = {https://github.com/paulc91/shinyauthr},
 }
@@ -94,7 +94,7 @@

Citation

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/index.html b/index.html index 71b536c..0a37cd9 100644 --- a/index.html +++ b/index.html @@ -77,26 +77,28 @@ -

shinyauthr is an R package providing module functions that can be used to add an authentication layer to your shiny apps.

+ + +

shinyauthr is an R package providing module functions that can be used to add an authentication layer to your shiny apps.

Installation

You can install the package from CRAN.

-install.packages("shinyauthr")
+install.packages("shinyauthr")

Or the development version from github with the remotes package.

-remotes::install_github("paulc91/shinyauthr")
+remotes::install_github("paulc91/shinyauthr")

Run example apps

Code for example apps using various UI frameworks can be found in inst/shiny-examples. You can launch 3 example apps with the runExample function.

-# login with user1 pass1 or user2 pass2
-shinyauthr::runExample("basic")
-shinyauthr::runExample("shinydashboard")
-shinyauthr::runExample("navbarPage")
+# login with user1 pass1 or user2 pass2 +shinyauthr::runExample("basic") +shinyauthr::runExample("shinydashboard") +shinyauthr::runExample("navbarPage")

Usage @@ -111,51 +113,51 @@

Usage

Note: the server modules use shiny’s new (version >= 1.5.0) shiny::moduleServer method as opposed to the shiny::callModule method used by the now deprecated shinyauthr::login and shinyauthr::logout functions. These functions will remain in the package for backwards compatibility but it is recommended you migrate to the new server functions. This will require some adjustments to the module server function calling method used in your app. For details on how to migrate see the ‘Migrating from callModule to moduleServer’ section of Modularizing Shiny app code.

Below is a minimal reproducible example of how to use the authentication modules in a shiny app. Note that this package invisibly calls shinyjs::useShinyjs() internally and there is no need for you to do so yourself (although there is no harm if you do).

-library(shiny)
-
-# dataframe that holds usernames, passwords and other user data
-user_base <- tibble::tibble(
-  user = c("user1", "user2"),
-  password = c("pass1", "pass2"),
-  permissions = c("admin", "standard"),
-  name = c("User One", "User Two")
-)
-
-ui <- fluidPage(
-  # add logout button UI
-  div(class = "pull-right", shinyauthr::logoutUI(id = "logout")),
-  # add login panel UI function
-  shinyauthr::loginUI(id = "login"),
-  # setup table output to show user info after login
-  tableOutput("user_table")
-)
-
-server <- function(input, output, session) {
-
-  # call login module supplying data frame, 
-  # user and password cols and reactive trigger
-  credentials <- shinyauthr::loginServer(
-    id = "login",
-    data = user_base,
-    user_col = user,
-    pwd_col = password,
-    log_out = reactive(logout_init())
-  )
-
-  # call the logout module with reactive trigger to hide/show
-  logout_init <- shinyauthr::logoutServer(
-    id = "logout",
-    active = reactive(credentials()$user_auth)
-  )
-
-  output$user_table <- renderTable({
-    # use req to only render results when credentials()$user_auth is TRUE
-    req(credentials()$user_auth)
-    credentials()$info
-  })
-}
-
-shinyApp(ui = ui, server = server)
+library(shiny) + +# dataframe that holds usernames, passwords and other user data +user_base <- tibble::tibble( + user = c("user1", "user2"), + password = c("pass1", "pass2"), + permissions = c("admin", "standard"), + name = c("User One", "User Two") +) + +ui <- fluidPage( + # add logout button UI + div(class = "pull-right", shinyauthr::logoutUI(id = "logout")), + # add login panel UI function + shinyauthr::loginUI(id = "login"), + # setup table output to show user info after login + tableOutput("user_table") +) + +server <- function(input, output, session) { + + # call login module supplying data frame, + # user and password cols and reactive trigger + credentials <- shinyauthr::loginServer( + id = "login", + data = user_base, + user_col = user, + pwd_col = password, + log_out = reactive(logout_init()) + ) + + # call the logout module with reactive trigger to hide/show + logout_init <- shinyauthr::logoutServer( + id = "logout", + active = reactive(credentials()$user_auth) + ) + + output$user_table <- renderTable({ + # use req to only render results when credentials()$user_auth is TRUE + req(credentials()$user_auth) + credentials()$info + }) +} + +shinyApp(ui = ui, server = server)

Details @@ -177,95 +179,95 @@

Hashing Passwords with sodium @@ -274,31 +276,31 @@

Hashing Passwords with sodiumIf you are hosting your user passwords on the internet, it is a good idea to first encrypt them with a hashing algorithm. You can use the sodium package to do this. Sodium uses a slow hashing algorithm that is specifically designed to protect stored passwords from brute-force attacks. More on this here. You then tell the shinyauthr::loginServer module that your passwords have been hashed by sodium and shinyauthr will then decrypt when login is requested. Your plain text passwords must be a character vector, not factors, when hashing for this to work as shiny inputs are passed as character strings.

For example, a sample user base like the following can be incorporated for use with shinyauthr:

-# create a user base then hash passwords with sodium
-# then save to an rds file in app directory
-library(sodium)
-
-user_base <- tibble::tibble(
-  user = c("user1", "user2"),
-  password = purrr::map_chr(c("pass1", "pass2"), sodium::password_store),
-  permissions = c("admin", "standard"),
-  name = c("User One", "User Two")
-)
-
-saveRDS(user_base, "user_base.rds")
+# create a user base then hash passwords with sodium +# then save to an rds file in app directory +library(sodium) + +user_base <- tibble::tibble( + user = c("user1", "user2"), + password = purrr::map_chr(c("pass1", "pass2"), sodium::password_store), + permissions = c("admin", "standard"), + name = c("User One", "User Two") +) + +saveRDS(user_base, "user_base.rds")

-# in your app code, read in the user base rds file
-user_base <- readRDS("user_base.rds")
+# in your app code, read in the user base rds file +user_base <- readRDS("user_base.rds")
-# then when calling the module set sodium_hashed = TRUE
-credentials <- shinyauthr::loginServer(
-  id = "login",
-  data = user_base,
-  user_col = user,
-  pwd_col = password,
-  sodium_hashed = TRUE,
-  log_out = reactive(logout_init())
-)
+# then when calling the module set sodium_hashed = TRUE +credentials <- shinyauthr::loginServer( + id = "login", + data = user_base, + user_col = user, + pwd_col = password, + sodium_hashed = TRUE, + log_out = reactive(logout_init()) +)

Credits @@ -358,7 +360,8 @@

Dev status

@@ -375,7 +378,7 @@

Dev status

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/news/index.html b/news/index.html index f3f4985..4299780 100644 --- a/news/index.html +++ b/news/index.html @@ -53,6 +53,13 @@

Changelog

Source: NEWS.md
+
+ +
-
+
-
+
-

If you plan to use hashed passwords with shinyauthr you now must use the sodium package to hash your passwords and the sodium_hashed = TRUE argument of the shinyauthr::login module call for decryption to work appropriately.

+

If you plan to use hashed passwords with shinyauthr you now must use the sodium package to hash your passwords and the sodium_hashed = TRUE argument of the shinyauthr::login module call for decryption to work appropriately.

This means that previously used hashed and algo arguments that interfaced with the digest package are now deprecated. If you had previously hashed your passwords with the digest package to use with shinyauthr, please re-hash them with sodium and use the sodium_hashed argument instead.

Sorry for this breaking change, but sodium hashing provides added protection against brute-force attacks on stored passwords. More information on this here.

@@ -85,7 +95,7 @@

Deprecated
-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/reference/login.html b/reference/login.html index 9812e8d..4a75821 100644 --- a/reference/login.html +++ b/reference/login.html @@ -63,36 +63,65 @@

login server module (deprecated)

Arguments

input

shiny input

+ +
output

shiny output

+ +
session

shiny session

+ +
data

data frame or tibble containing usernames, passwords and other user data

+ +
user_col

bare (unquoted) column name containing usernames

+ +
pwd_col

bare (unquoted) column name containing passwords

+ +
sodium_hashed

have the passwords been hash encrypted using the sodium package? defaults to FALSE

+ +
hashed

Deprecated. shinyauthr now uses the sodium package for password hashing and decryption. If you have previously hashed your passwords with the digest package to use with shinyauthr please re-hash them with sodium for decryption to work.

+ +
algo

Deprecated

+ +
log_out

[reactive] supply the returned reactive from logout here to trigger a user logout

+ +
sessionid_col

bare (unquoted) column name containing session ids

+ +
cookie_getter

a function that returns a data.frame with at least two columns: user and session

+ +
cookie_setter

a function with two parameters: user and session. The function must save these to a database.

+ +
reload_on_logout

should app force reload on logout?

+

Value

-

The module will return a reactive 2 element list to your main application. + + +

The module will return a reactive 2 element list to your main application. First element user_auth is a boolean indicating whether there has been a successful login or not. Second element info will be the data frame provided to the function, filtered to the row matching the successfully logged in username. @@ -109,17 +138,17 @@

Details

Examples

-
if (FALSE) {
-user_credentials <- shiny::callModule(
-  login,
-  id = "login",
-  data = user_base,
-  user_col = user,
-  pwd_col = password,
-  log_out = reactive(logout_init())
-)
-}
-
+    
if (FALSE) {
+user_credentials <- shiny::callModule(
+  login,
+  id = "login",
+  data = user_base,
+  user_col = user,
+  pwd_col = password,
+  log_out = reactive(logout_init())
+)
+}
+
 
@@ -134,7 +163,7 @@

Examples

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/reference/loginServer.html b/reference/loginServer.html index 21dfac4..3eefe4d 100644 --- a/reference/loginServer.html +++ b/reference/loginServer.html @@ -59,49 +59,73 @@

login server module

-
loginServer(
-  id,
-  data,
-  user_col,
-  pwd_col,
-  sodium_hashed = FALSE,
-  log_out = shiny::reactiveVal(),
-  reload_on_logout = FALSE,
-  cookie_logins = FALSE,
-  sessionid_col,
-  cookie_getter,
-  cookie_setter
-)
+
loginServer(
+  id,
+  data,
+  user_col,
+  pwd_col,
+  sodium_hashed = FALSE,
+  log_out = shiny::reactiveVal(),
+  reload_on_logout = FALSE,
+  cookie_logins = FALSE,
+  sessionid_col,
+  cookie_getter,
+  cookie_setter
+)

Arguments

id

An ID string that corresponds with the ID used to call the module's UI function

+ +
data
-

data frame or tibble containing user names, passwords and other user data

+

data frame or tibble containing user names, passwords and other user data. Can be either +a static object or a shiny reactive object

+ +
user_col

bare (unquoted) or quoted column name containing user names

+ +
pwd_col

bare (unquoted) or quoted column name containing passwords

+ +
sodium_hashed

have the passwords been hash encrypted using the sodium package? defaults to FALSE

+ +
log_out

[reactive] supply the returned reactive from logoutServer here to trigger a user logout

+ +
reload_on_logout

should app force a session reload on logout?

+ +
cookie_logins

enable automatic logins via browser cookies?

+ +
sessionid_col

bare (unquoted) or quoted column name containing session ids

+ +
cookie_getter

a function that returns a data.frame with at least two columns: user and session

+ +
cookie_setter

a function with two parameters: user and session. The function must save these to a database.

+

Value

-

The module will return a reactive 2 element list to your main application. + + +

The module will return a reactive 2 element list to your main application. First element user_auth is a boolean indicating whether there has been a successful login or not. Second element info will be the data frame provided to the function, filtered to the row matching the successfully logged in username. @@ -117,55 +141,55 @@

Details

Examples

-
library(shiny)
+    
library(shiny)
 #> 
 #> Attaching package: ‘shiny’
 #> The following object is masked from ‘package:shinyauthr’:
 #> 
 #>     runExample
-
-# dataframe that holds usernames, passwords and other user data
-user_base <- dplyr::tibble(
-  user = c("user1", "user2"),
-  password = c("pass1", "pass2"),
-  permissions = c("admin", "standard"),
-  name = c("User One", "User Two")
-)
-
-ui <- fluidPage(
-  # add logout button UI
-  div(class = "pull-right", shinyauthr::logoutUI(id = "logout")),
-  # add login panel UI function
-  shinyauthr::loginUI(id = "login"),
-  # setup table output to show user info after login
-  tableOutput("user_table")
-)
-
-server <- function(input, output, session) {
-  # call login module supplying data frame, 
-  # user and password cols and reactive trigger
-  credentials <- shinyauthr::loginServer(
-    id = "login",
-    data = user_base,
-    user_col = user,
-    pwd_col = password,
-    log_out = reactive(logout_init())
-  )
-  
-  # call the logout module with reactive trigger to hide/show
-  logout_init <- shinyauthr::logoutServer(
-    id = "logout",
-    active = reactive(credentials()$user_auth)
-  )
-  
-  output$user_table <- renderTable({
-    # use req to only render results when credentials()$user_auth is TRUE
-    req(credentials()$user_auth)
-    credentials()$info
-  })
-}
-
-if (interactive()) shinyApp(ui = ui, server = server)
+
+# dataframe that holds usernames, passwords and other user data
+user_base <- dplyr::tibble(
+  user = c("user1", "user2"),
+  password = c("pass1", "pass2"),
+  permissions = c("admin", "standard"),
+  name = c("User One", "User Two")
+)
+
+ui <- fluidPage(
+  # add logout button UI
+  div(class = "pull-right", shinyauthr::logoutUI(id = "logout")),
+  # add login panel UI function
+  shinyauthr::loginUI(id = "login"),
+  # setup table output to show user info after login
+  tableOutput("user_table")
+)
+
+server <- function(input, output, session) {
+  # call login module supplying data frame, 
+  # user and password cols and reactive trigger
+  credentials <- shinyauthr::loginServer(
+    id = "login",
+    data = user_base,
+    user_col = user,
+    pwd_col = password,
+    log_out = reactive(logout_init())
+  )
+  
+  # call the logout module with reactive trigger to hide/show
+  logout_init <- shinyauthr::logoutServer(
+    id = "logout",
+    active = reactive(credentials()$user_auth)
+  )
+  
+  output$user_table <- renderTable({
+    # use req to only render results when credentials()$user_auth is TRUE
+    req(credentials()$user_auth)
+    credentials()$info
+  })
+}
+
+if (interactive()) shinyApp(ui = ui, server = server)
 
@@ -180,7 +204,7 @@

Examples

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/reference/loginUI.html b/reference/loginUI.html index 8ed6b6f..c4bb525 100644 --- a/reference/loginUI.html +++ b/reference/loginUI.html @@ -59,91 +59,110 @@

login UI module

-
loginUI(
-  id,
-  title = "Please log in",
-  user_title = "User Name",
-  pass_title = "Password",
-  login_title = "Log in",
-  login_btn_class = "btn-primary",
-  error_message = "Invalid username or password!",
-  additional_ui = NULL,
-  cookie_expiry = 7
-)
+
loginUI(
+  id,
+  title = "Please log in",
+  user_title = "User Name",
+  pass_title = "Password",
+  login_title = "Log in",
+  login_btn_class = "btn-primary",
+  error_message = "Invalid username or password!",
+  additional_ui = NULL,
+  cookie_expiry = 7
+)

Arguments

id

An ID string that corresponds with the ID used to call the module's server function

+ +
title

header title for the login panel

+ +
user_title

label for the user name text input

+ +
pass_title

label for the password text input

+ +
login_title

label for the login button

+ +
login_btn_class

bootstrap class for the login button. defaults to "btn-primary"

+ +
error_message

message to display after failed login

+ +
additional_ui
-

additional shiny UI element(s) to add below login button. Wrap multiple inside shiny::tagList()

+

additional shiny UI element(s) to add below login button. Wrap multiple inside shiny::tagList()

+ +
cookie_expiry

number of days to request browser to retain login cookie

+

Value

-

Shiny UI login panel with user name text input, password text input and login action button.

+ + +

Shiny UI login panel with user name text input, password text input and login action button.

Examples

-
library(shiny)
-
-# dataframe that holds usernames, passwords and other user data
-user_base <- dplyr::tibble(
-  user = c("user1", "user2"),
-  password = c("pass1", "pass2"),
-  permissions = c("admin", "standard"),
-  name = c("User One", "User Two")
-)
-
-ui <- fluidPage(
-  # add logout button UI
-  div(class = "pull-right", shinyauthr::logoutUI(id = "logout")),
-  # add login panel UI function
-  shinyauthr::loginUI(id = "login"),
-  # setup table output to show user info after login
-  tableOutput("user_table")
-)
-
-server <- function(input, output, session) {
-  # call login module supplying data frame, 
-  # user and password cols and reactive trigger
-  credentials <- shinyauthr::loginServer(
-    id = "login",
-    data = user_base,
-    user_col = user,
-    pwd_col = password,
-    log_out = reactive(logout_init())
-  )
-  
-  # call the logout module with reactive trigger to hide/show
-  logout_init <- shinyauthr::logoutServer(
-    id = "logout",
-    active = reactive(credentials()$user_auth)
-  )
-  
-  output$user_table <- renderTable({
-    # use req to only render results when credentials()$user_auth is TRUE
-    req(credentials()$user_auth)
-    credentials()$info
-  })
-}
-
-if (interactive()) shinyApp(ui = ui, server = server)
+    
library(shiny)
+
+# dataframe that holds usernames, passwords and other user data
+user_base <- dplyr::tibble(
+  user = c("user1", "user2"),
+  password = c("pass1", "pass2"),
+  permissions = c("admin", "standard"),
+  name = c("User One", "User Two")
+)
+
+ui <- fluidPage(
+  # add logout button UI
+  div(class = "pull-right", shinyauthr::logoutUI(id = "logout")),
+  # add login panel UI function
+  shinyauthr::loginUI(id = "login"),
+  # setup table output to show user info after login
+  tableOutput("user_table")
+)
+
+server <- function(input, output, session) {
+  # call login module supplying data frame, 
+  # user and password cols and reactive trigger
+  credentials <- shinyauthr::loginServer(
+    id = "login",
+    data = user_base,
+    user_col = user,
+    pwd_col = password,
+    log_out = reactive(logout_init())
+  )
+  
+  # call the logout module with reactive trigger to hide/show
+  logout_init <- shinyauthr::logoutServer(
+    id = "logout",
+    active = reactive(credentials()$user_auth)
+  )
+  
+  output$user_table <- renderTable({
+    # use req to only render results when credentials()$user_auth is TRUE
+    req(credentials()$user_auth)
+    credentials()$info
+  })
+}
+
+if (interactive()) shinyApp(ui = ui, server = server)
 
@@ -158,7 +177,7 @@

Examples

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/reference/logout.html b/reference/logout.html index 807886b..6b02428 100644 --- a/reference/logout.html +++ b/reference/logout.html @@ -63,18 +63,28 @@

logout server module (deprecated)

Arguments

input

shiny input

+ +
output

shiny output

+ +
session

shiny session

+ +
active

[reactive] supply the returned user_auth boolean reactive from login here to hide/show the logout button

+

Value

-

Reactive boolean, to be supplied as the log_out argument of the -login module to trigger the logout process

+ + +

Reactive boolean, to be supplied as the log_out argument of the

+

+

login module to trigger the logout process

Details

@@ -87,14 +97,14 @@

Details

Examples

-
if (FALSE) {
-logout_init <- shiny::callModule(
-  logout,
-  id = "logout",
-  active = reactive(user_credentials()$user_auth)
-)
-}
-
+    
if (FALSE) {
+logout_init <- shiny::callModule(
+  logout,
+  id = "logout",
+  active = reactive(user_credentials()$user_auth)
+)
+}
+
 
@@ -109,7 +119,7 @@

Examples

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/reference/logoutServer.html b/reference/logoutServer.html index 7139d72..111dece 100644 --- a/reference/logoutServer.html +++ b/reference/logoutServer.html @@ -59,23 +59,31 @@

logout server module

-
logoutServer(id, active, ...)
+
logoutServer(id, active, ...)

Arguments

id

An ID string that corresponds with the ID used to call the module's UI function

+ +
active

reactive supply the returned user_auth boolean reactive from loginServer here to hide/show the logout button

+ +
...

arguments passed to toggle

+

Value

-

Reactive boolean, to be supplied as the log_out argument of the -loginServer module to trigger the logout process

+ + +

Reactive boolean, to be supplied as the log_out argument of the

+

+

loginServer module to trigger the logout process

Details

@@ -87,50 +95,50 @@

Details

Examples

-
library(shiny)
-
-# dataframe that holds usernames, passwords and other user data
-user_base <- dplyr::tibble(
-  user = c("user1", "user2"),
-  password = c("pass1", "pass2"),
-  permissions = c("admin", "standard"),
-  name = c("User One", "User Two")
-)
-
-ui <- fluidPage(
-  # add logout button UI
-  div(class = "pull-right", shinyauthr::logoutUI(id = "logout")),
-  # add login panel UI function
-  shinyauthr::loginUI(id = "login"),
-  # setup table output to show user info after login
-  tableOutput("user_table")
-)
-
-server <- function(input, output, session) {
-  # call login module supplying data frame, 
-  # user and password cols and reactive trigger
-  credentials <- shinyauthr::loginServer(
-    id = "login",
-    data = user_base,
-    user_col = user,
-    pwd_col = password,
-    log_out = reactive(logout_init())
-  )
-  
-  # call the logout module with reactive trigger to hide/show
-  logout_init <- shinyauthr::logoutServer(
-    id = "logout",
-    active = reactive(credentials()$user_auth)
-  )
-  
-  output$user_table <- renderTable({
-    # use req to only render results when credentials()$user_auth is TRUE
-    req(credentials()$user_auth)
-    credentials()$info
-  })
-}
-
-if (interactive()) shinyApp(ui = ui, server = server)
+    
library(shiny)
+
+# dataframe that holds usernames, passwords and other user data
+user_base <- dplyr::tibble(
+  user = c("user1", "user2"),
+  password = c("pass1", "pass2"),
+  permissions = c("admin", "standard"),
+  name = c("User One", "User Two")
+)
+
+ui <- fluidPage(
+  # add logout button UI
+  div(class = "pull-right", shinyauthr::logoutUI(id = "logout")),
+  # add login panel UI function
+  shinyauthr::loginUI(id = "login"),
+  # setup table output to show user info after login
+  tableOutput("user_table")
+)
+
+server <- function(input, output, session) {
+  # call login module supplying data frame, 
+  # user and password cols and reactive trigger
+  credentials <- shinyauthr::loginServer(
+    id = "login",
+    data = user_base,
+    user_col = user,
+    pwd_col = password,
+    log_out = reactive(logout_init())
+  )
+  
+  # call the logout module with reactive trigger to hide/show
+  logout_init <- shinyauthr::logoutServer(
+    id = "logout",
+    active = reactive(credentials()$user_auth)
+  )
+  
+  output$user_table <- renderTable({
+    # use req to only render results when credentials()$user_auth is TRUE
+    req(credentials()$user_auth)
+    credentials()$info
+  })
+}
+
+if (interactive()) shinyApp(ui = ui, server = server)
 
@@ -145,7 +153,7 @@

Examples

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/reference/logoutUI.html b/reference/logoutUI.html index 2eb7df1..d211565 100644 --- a/reference/logoutUI.html +++ b/reference/logoutUI.html @@ -59,79 +59,90 @@

logout UI module

-
logoutUI(
-  id,
-  label = "Log out",
-  icon = NULL,
-  class = "btn-danger",
-  style = "color: white;"
-)
+
logoutUI(
+  id,
+  label = "Log out",
+  icon = NULL,
+  class = "btn-danger",
+  style = "color: white;"
+)

Arguments

id

An ID string that corresponds with the ID used to call the module's server function

+ +
label

label for the logout button

+ +
icon

An optional icon to appear on the button.

+ +
class

bootstrap class for the logout button

+ +
style

css styling for the logout button

+

Value

-

Shiny UI action button

+ + +

Shiny UI action button

Examples

-
library(shiny)
-
-# dataframe that holds usernames, passwords and other user data
-user_base <- dplyr::tibble(
-  user = c("user1", "user2"),
-  password = c("pass1", "pass2"),
-  permissions = c("admin", "standard"),
-  name = c("User One", "User Two")
-)
-
-ui <- fluidPage(
-  # add logout button UI
-  div(class = "pull-right", shinyauthr::logoutUI(id = "logout")),
-  # add login panel UI function
-  shinyauthr::loginUI(id = "login"),
-  # setup table output to show user info after login
-  tableOutput("user_table")
-)
-
-server <- function(input, output, session) {
-  # call login module supplying data frame, 
-  # user and password cols and reactive trigger
-  credentials <- shinyauthr::loginServer(
-    id = "login",
-    data = user_base,
-    user_col = user,
-    pwd_col = password,
-    log_out = reactive(logout_init())
-  )
-  
-  # call the logout module with reactive trigger to hide/show
-  logout_init <- shinyauthr::logoutServer(
-    id = "logout",
-    active = reactive(credentials()$user_auth)
-  )
-  
-  output$user_table <- renderTable({
-    # use req to only render results when credentials()$user_auth is TRUE
-    req(credentials()$user_auth)
-    credentials()$info
-  })
-}
-
-if (interactive()) shinyApp(ui = ui, server = server)
+    
library(shiny)
+
+# dataframe that holds usernames, passwords and other user data
+user_base <- dplyr::tibble(
+  user = c("user1", "user2"),
+  password = c("pass1", "pass2"),
+  permissions = c("admin", "standard"),
+  name = c("User One", "User Two")
+)
+
+ui <- fluidPage(
+  # add logout button UI
+  div(class = "pull-right", shinyauthr::logoutUI(id = "logout")),
+  # add login panel UI function
+  shinyauthr::loginUI(id = "login"),
+  # setup table output to show user info after login
+  tableOutput("user_table")
+)
+
+server <- function(input, output, session) {
+  # call login module supplying data frame, 
+  # user and password cols and reactive trigger
+  credentials <- shinyauthr::loginServer(
+    id = "login",
+    data = user_base,
+    user_col = user,
+    pwd_col = password,
+    log_out = reactive(logout_init())
+  )
+  
+  # call the logout module with reactive trigger to hide/show
+  logout_init <- shinyauthr::logoutServer(
+    id = "logout",
+    active = reactive(credentials()$user_auth)
+  )
+  
+  output$user_table <- renderTable({
+    # use req to only render results when credentials()$user_auth is TRUE
+    req(credentials()$user_auth)
+    credentials()$info
+  })
+}
+
+if (interactive()) shinyApp(ui = ui, server = server)
 
@@ -146,7 +157,7 @@

Examples

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.

diff --git a/reference/runExample.html b/reference/runExample.html index 54e98fe..51249c2 100644 --- a/reference/runExample.html +++ b/reference/runExample.html @@ -61,27 +61,30 @@

Run shinyauthr examples

-
runExample(example = c("basic", "shinydashboard", "navbarPage"))
+
runExample(example = c("basic", "shinydashboard", "navbarPage"))

Arguments

example

The app to launch. Options are "basic", "shinydashboard" or "navbarPage"

+

Value

-

No return value, a shiny app is launched.

+ + +

No return value, a shiny app is launched.

Examples

-
## Only run this example in interactive R sessions
-if (interactive()) {
-  runExample("basic")
-  runExample("shinydashboard")
-  runExample("navbarPage")
-}
+    
## Only run this example in interactive R sessions
+if (interactive()) {
+  runExample("basic")
+  runExample("shinydashboard")
+  runExample("navbarPage")
+}
 
@@ -96,7 +99,7 @@

Examples

-

Site built with pkgdown 2.0.3.

+

Site built with pkgdown 2.0.7.