Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI not showing after login #36

Closed
GeorgeOduor opened this issue Jun 1, 2020 · 9 comments
Closed

UI not showing after login #36

GeorgeOduor opened this issue Jun 1, 2020 · 9 comments

Comments

@GeorgeOduor
Copy link

Hello, i have installed the package well and created my app. Unfortunately after logging in successfully,I am not able to view my UI elements.

Honestly, this has brought down my whole project down . Can someone help me.

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinymanager)
library(lubridate)

ui.r
ui <- dashboardPagePlus(title = "myapp",skin = 'purple',
                        collapse_sidebar = T,sidebar_background = "light",enable_preloader = T,loading_duration = 1,md = T,
    header <- dashboardHeaderPlus(),
    sidebar = dashboardSidebar(collapsed = TRUE),
    body = dashboardBody(),
    footer = dashboardFooter(left_text = HTML(paste("&copy;",year(Sys.Date()))),
right_text = Sys.time())
)

ui <- secure_app(ui)

server.r

credentials <- data.frame(
    user = c("1", "2"), # mandatory
    password = c("", ""), # mandatory
    start = c("2019-04-15"), # optinal (all others)
    expire = c(NA, "2019-12-31"),
    admin = c(FALSE, TRUE),
    comment = "Simple and secure authentification mechanism 
  for single ‘Shiny’ applications.",
    stringsAsFactors = FALSE
)

server <- function(input, output, session) {
    
    # call the server part
    # check_credentials returns a function to authenticate users
    res_auth <- secure_server(
        check_credentials = check_credentials(credentials),keep_token = T
    ) 
    output$auth_output <- renderPrint({
        reactiveValuesToList(res_auth)
    })
    
    # your classic server logic
    
}

@pvictor
Copy link
Collaborator

pvictor commented Jun 2, 2020

Hello,

Your example is working for me, can you share more info, like result of sessioninfo::session_info(), and details from JavaScript console maybe ?

Victor

@bthieurmel
Copy link
Contributor

In complement, using shinymanager, all the server code is sourced at the beginning but the ui is hidden / blocked until logging.

So, in some case with not enough control, you can have a application without any problems without using shinymanager but having some errors using shinymanager resulting in not able to view UI... (unfortunately...!)

You can normally see this kind of case / error in your R console. The cause is most of the time some controls in observe / reactive on input that are not existing on begining.... (like if(input$x > 10))

Better solution : see all errors on R console and add control (like if(!is.null(input$x) && input$x > 10))

Faster solution : add a global observer on top of your all your server code like this :

server <- function(input, output, session) {
  
  auth_out <- secure_server(....)
  
  observe({
    if(is.null(input$shinymanager_where) || (!is.null(input$shinymanager_where) && input$shinymanager_where %in% "application")){
      
      # your server app code
    }
  })
}

@MeganBeckett
Copy link

Hi there,

I seem to be having a similar problem where certain UI elements do not render (using renderUI and uiOutput) when the user logs in and first views the landing page of the app.

If I remove the authentication, then these UI elements render perfectly.

But, with the authentication, they just do not appear. I can "trigger" these elements to appear by clicking around for awhile.

Any ideas?

@pvictor
Copy link
Collaborator

pvictor commented Jun 4, 2020

Hello,

There is a lag between your UI and the server, since {shinymanger} hides the UI until authentication is successful. It is therefore possible that some of them are not defined and are NULL, we recommend to use in all your reactive functions the req function to validate the inputs.

If you can isolate the problem and provide a reproducible example it will be great.

Victor

@GeorgeOduor
Copy link
Author

Hello,

Your example is working for me, can you share more info, like result of sessioninfo::session_info(), and details from JavaScript console maybe ?

Victor

That's what keeps me wondering.I have two laptops.It works perfectly fine in one bot not in the other which initially was also working fine.

@Oliversinn
Copy link

I had a similar problem. I checked in the web console and it seems that shinymanager has a bug while using shinycssloader. I got to this conclusion because whitout shinymanager my app worked just fine.
this is the error:
imagen

If i change my inputs it will work just fine, but the first impression its like it's not working so the users complain and get out of the app.

@pvictor
Copy link
Collaborator

pvictor commented Jul 21, 2020

@Oliversinn can you provide a minimal reproducible example where it's not working ? We'll look into

@Oliversinn
Copy link

There isn't any erro or warning in the R console so its realy hard to provide an example of what really is causing the problem.

But in my UI i have withSpinner() wrapper in all my plots. Like withSpinner(leafletOutput("myOutput")) or withSpinner(plotlyOutput("myOutput")). If i have this loader my app wont work at first, i must change inputs to refresh it an fix it (like magically). When I remove all the witSpinner() wrappers it would work fine.

The only console message I get it's the one i posted :( I know its hard to debug with only this information but its all i got.

@Oliversinn
Copy link

I solved it just using a different type of package to use loaders tho...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants