Closed Raymond-KT closed 3 years ago
Hello,
Be sure to set enable_admin = TRUE
in secure_app()
.
Victor
Thank you for your kindness, But, I use custom auth_ui for my app instead use of secure_app().
In this case, where should I put 'enable_admin = TRUE'?
Admin mode is only available using secure_app
/ secure_server
logic (secure_app
use auth_ui
, and you can pass arguments from secure_app
to auth_ui
)
Admin mode is only available using
secure_app
/secure_server
logic (secure_app
useauth_ui
, and you can pass arguments fromsecure_app
toauth_ui
)
Oh!!! It's you! pvictor!! you are my hero!! I've been helped before! auth_ui Issue
Then, there is no way to use Admin mode in my situation, right? In the previous question, if I want to use a customized UI(auth_ui), secure_app should not be used.
` library(shiny) library(shinymanager) library(shinydashboard)
credentials <- data.frame( user = c("fanny", "victor"), password = c(scrypt::hashPassword("azerty"), scrypt::hashPassword("12345")), is_hashed_password = TRUE, comment = c("alsace", "auvergne"), stringsAsFactors = FALSE )
ui <- dashboardPage( dashboardHeader(), dashboardSidebar(), dashboardBody(
auth_ui(
id = "auth",
# add image on top ?
tags_top =
tags$div(
tags$h4("Demo", style = "align:center"),
tags$img(
src = "https://www.r-project.org/logo/Rlogo.png", width = 100
)
),
# add information on bottom ?
tags_bottom = tags$div(
tags$p(
"For any question, please contact ",
tags$a(
href = "mailto:someone@example.com?Subject=Shiny%20aManager",
target="_top", "administrator"
)
)
)
),
tags$div("Normal body content")
) )
server <- function(input, output) {
auth <- callModule( module = auth_server, id = "auth", check_credentials = check_credentials(credentials) )
}
shinyApp(ui, server) `
Yes you can use tags_top
and tags_bottom
with secure_app
. With your shinydashboard example, it'll gives something like:
library(shiny)
library(shinydashboard)
library(shinymanager)
# Credentials as data.frame
credentials <- data.frame(
user = c("shiny", "shinymanager"), # mandatory
password = c("azerty", "12345"), # mandatory
stringsAsFactors = FALSE
)
# Change labels
set_labels(
language = "en",
"Please authenticate" = "Bitte authentifizieren",
"Username:" = "Benutzername:",
"Password:" = "Passwort:",
"Login" = "Anmeldung"
)
# Classic shinydashboard
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(),
title = "Dashboard example"
)
# Wrap your UI with secure_app
ui <- secure_app(
ui = ui,
tags_top =
tags$div(
tags$h4("Demo", style = "align:center"),
tags$img(
src = "https://www.r-project.org/logo/Rlogo.png", width = 100
)
),
# add information on bottom ?
tags_bottom = tags$div(
tags$p(
"For any question, please contact ",
tags$a(
href = "mailto:someone@example.com?Subject=Shiny%20aManager",
target="_top", "administrator"
)
)
)
)
# Server
server <- function(input, output, session) {
# With creadentials data.frame (for the example)
res_auth <- secure_server(
check_credentials = check_credentials(credentials)
)
# If you have a SQLite database, you can use:
# res_auth <- secure_server(
# check_credentials = check_credentials(
# "path/to/database.sqlite",
# passphrase = "mypassphrase"
# )
# )
# your classic server logic
}
shinyApp(ui, server)
And to enable admin mode, replace credentials with an SQLite database created with create_db()
and set enable_admin = TRUE
in secure_app()
.
I really appreciate your kindness, Finally, I solved my problem perfectly, cause of your solution!!!
I don't know how to express my gratitude. TT
If you have any plans to come to South Korea, please contact me!! I want to return the favor.
You're welcome 😄 , glad you find a solution !
Ahaha no plans to travel soon I'm afraid, but I keep your invitation in mind, South Korea must be a beautiful place to visit !
Thank you so much. I wish you good health always. Don't forget to call me when you come :)
Hello, I appreciate the awesome shinymanager package!!
I use shinydashboard and shinymanager for my web site.
There is no problem when I use No DB shinymanager, But when I use SQL DB with shinymanager, I can't find log out/admin button.
So I can't log in to administrator mode.
Is it impossible to use admin mode on shinydashboard dashboard body?
Or Is there another way to log in to administrator mode?
Thank you!!!