@@ -38,7 +38,7 @@ secure_app <- function(ui, ..., enable_admin = FALSE, head_auth = NULL, theme =
3838 if (is.null(theme )) {
3939 theme <- " shinymanager/css/readable.min.css"
4040 }
41-
41+
4242 function (request ) {
4343 query <- parseQueryString(request $ QUERY_STRING )
4444 token <- query $ token
@@ -57,10 +57,7 @@ secure_app <- function(ui, ..., enable_admin = FALSE, head_auth = NULL, theme =
5757 )
5858 return (pwd_ui )
5959 }
60- if (isTRUE(enable_admin ) && .tok $ is_admin(token ) & identical(admin , " true" )) {
61- if (is.null(.tok $ get_sqlite_path())) {
62- warning(" Admin mode is only available when using a SQLite database!" , call. = FALSE )
63- }
60+ if (isTRUE(enable_admin ) && .tok $ is_admin(token ) & identical(admin , " true" ) & ! is.null(.tok $ get_sqlite_path())) {
6461 navbarPage(
6562 title = " Admin" ,
6663 theme = theme ,
@@ -93,7 +90,7 @@ secure_app <- function(ui, ..., enable_admin = FALSE, head_auth = NULL, theme =
9390 )
9491 )
9592 } else {
96- if (isTRUE(enable_admin ) && .tok $ is_admin(token )) {
93+ if (isTRUE(enable_admin ) && .tok $ is_admin(token ) && ! is.null( .tok $ get_sqlite_path()) ) {
9794 menu <- fab_button(
9895 actionButton(
9996 inputId = " .shinymanager_logout" ,
@@ -109,6 +106,9 @@ secure_app <- function(ui, ..., enable_admin = FALSE, head_auth = NULL, theme =
109106 )
110107 )
111108 } else {
109+ if (isTRUE(enable_admin ) && .tok $ is_admin(token ) && is.null(.tok $ get_sqlite_path())) {
110+ warning(" Admin mode is only available when using a SQLite database!" , call. = FALSE )
111+ }
112112 menu <- fab_button(
113113 actionButton(
114114 inputId = " .shinymanager_logout" ,
@@ -152,27 +152,27 @@ secure_app <- function(ui, ..., enable_admin = FALSE, head_auth = NULL, theme =
152152# '
153153# ' @rdname secure-app
154154secure_server <- function (check_credentials , timeout = 15 , session = shiny :: getDefaultReactiveDomain()) {
155-
155+
156156 isolate(resetQueryString(session = session ))
157157 token_start <- isolate(getToken(session = session ))
158-
158+
159159 callModule(
160160 module = auth_server ,
161161 id = " auth" ,
162162 check_credentials = check_credentials ,
163163 use_token = TRUE
164164 )
165-
165+
166166 callModule(
167167 module = pwd_server ,
168168 id = " password" ,
169169 user = reactiveValues(user = .tok $ get(token_start )$ user ),
170170 update_pwd = update_pwd ,
171171 use_token = TRUE
172172 )
173-
173+
174174 .tok $ set_timeout(timeout )
175-
175+
176176 path_sqlite <- .tok $ get_sqlite_path()
177177 if (! is.null(path_sqlite )) {
178178 callModule(
@@ -188,9 +188,9 @@ secure_server <- function(check_credentials, timeout = 15, session = shiny::getD
188188 passphrase = .tok $ get_passphrase()
189189 )
190190 }
191-
191+
192192 user_info_rv <- reactiveValues()
193-
193+
194194 observe({
195195 token <- getToken(session = session )
196196 if (! is.null(token )) {
@@ -200,33 +200,33 @@ secure_server <- function(check_credentials, timeout = 15, session = shiny::getD
200200 }
201201 }
202202 })
203-
203+
204204 observeEvent(session $ input $ .shinymanager_admin , {
205205 token <- getToken(session = session )
206206 updateQueryString(queryString = sprintf(" ?token=%s&admin=true" , token ), session = session , mode = " replace" )
207207 .tok $ reset_count(token )
208208 session $ reload()
209209 }, ignoreInit = TRUE )
210-
210+
211211 observeEvent(session $ input $ .shinymanager_app , {
212212 token <- getToken(session = session )
213213 updateQueryString(queryString = sprintf(" ?token=%s" , token ), session = session , mode = " replace" )
214214 .tok $ reset_count(token )
215215 session $ reload()
216216 }, ignoreInit = TRUE )
217-
217+
218218 observeEvent(session $ input $ .shinymanager_logout , {
219219 token <- getToken(session = session )
220220 logout_logs(token )
221221 .tok $ remove(token )
222222 clearQueryString(session = session )
223223 session $ reload()
224224 }, ignoreInit = TRUE )
225-
226-
227-
225+
226+
227+
228228 if (timeout > 0 ) {
229-
229+
230230 observeEvent(session $ input $ .shinymanager_timeout , {
231231 token <- getToken(session = session )
232232 if (! is.null(token )) {
@@ -238,7 +238,7 @@ secure_server <- function(check_credentials, timeout = 15, session = shiny::getD
238238 }
239239 }
240240 })
241-
241+
242242 observe({
243243 invalidateLater(30000 , session )
244244 token <- getToken(session = session )
@@ -251,9 +251,9 @@ secure_server <- function(check_credentials, timeout = 15, session = shiny::getD
251251 }
252252 }
253253 })
254-
254+
255255 }
256-
256+
257257 return (user_info_rv )
258258}
259259
0 commit comments