title: R shiny login hack
body: <p>Having tried the evaluation of the RStudio Shiny Pro Server I am not super enthused by the login/authentication mechanism as their is no simple mechanism to manage user accounts for clients to access a shiny app. </p>
  
  <p>As such I am attempting to create my own login mechanism within Shiny which for all intents and purposes is working ok, apart from the display of things within the <code>shinydashboard</code> framework. Things seem to cut off before all the content is displayed. My login code is a slight ammend to <a href="https://gist.github.com/withr/9001831" rel="noreferrer">https://gist.github.com/withr/9001831</a>, so thanks a bunch there.</p>
  
  <p>My code: </p>
  
  <pre><code>require(shiny)
  require(shinydashboard)
  
  my_username &lt;- "test"
  my_password &lt;- "abc"
  
  header &lt;- dashboardHeader(title = "my heading")
  sidebar &lt;- uiOutput("sidebarpanel")
  body &lt;- uiOutput("body")
  
  login &lt;- box(title = "Login",textInput("userName", "Username"),
               passwordInput("passwd", "Password"),
               br(),actionButton("Login", "Log in"))
  
  mainpage &lt;- "some data"
  
  ui &lt;- dashboardPage(header, sidebar, body)
  
  server &lt;- function(input, output, session) {
    USER &lt;&lt;- reactiveValues(Logged = Logged)
  
    observe({ 
      if (USER$Logged == FALSE) {
        if (!is.null(input$Login)) {
          if (input$Login &gt; 0) {
            Username &lt;- isolate(input$userName)
            Password &lt;- isolate(input$passwd)
            Id.username &lt;- which(my_username == Username)
            Id.password &lt;- which(my_password == Password)
            if (length(Id.username) &gt; 0 &amp; length(Id.password) &gt; 0) {
              if (Id.username == Id.password) {
                USER$Logged &lt;&lt;- TRUE
              } 
            }
          } 
        }
      }    
    })
  
    output$sidebarpanel &lt;- renderUI({
      if (USER$Logged == TRUE) { 
        dashboardSidebar(
          sidebarUserPanel("myuser",subtitle = a(icon("user"), "Logout", href="__logout__")),
          selectInput("in_var", "myvar", multiple = FALSE,
                    choices = c("option 1","option 2")),
          sidebarMenu(
            menuItem("Item 1", tabName = "t_item1", icon = icon("line-chart")),
            menuItem("Item 2", tabName = "t_item2", icon = icon("dollar")),
            menuItem("Item 3", tabName = "t_item3", icon = icon("credit-card")),
            menuItem("Item 4", tabName = "t_item4", icon = icon("share-alt"))
          ))}
    })
  
    output$body &lt;- renderUI({
      if (USER$Logged == TRUE) {
        dashboardBody(mainpage)
      }
      else {
        dashboardBody(login)
      }
    })
  }
  
  shinyApp(ui, server)
  </code></pre>
  
  <p>When I load the app it looks like this:
  <a href="https://i.stack.imgur.com/sy1kJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sy1kJ.png" alt="Initial sceen capture"></a></p>
  
  <p>If I then resize the screen slightly it fixes itself.<a href="https://i.stack.imgur.com/UAUoU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UAUoU.png" alt="Resize screen capture"></a></p>
  
  <p>Any thoughts on how to avoid the strange initial behaviour would be greatly appreciated..</p>