R shiny login hack

风格不统一 提交于 2019-12-03 14:46:48

I think that the problem can be fixed by putting the dashboardSidebar and dashboardBody function outside of the renderUI, just like:

header <- dashboardHeader(title = "my heading")
sidebar <- dashboardSidebar(uiOutput("sidebarpanel"))
body <- dashboardBody( uiOutput("body") )

It will create a empty side bar and a body that later you can fill using the renderUI function.

Since you have multiple components in "sidebarpanel" you can group then by replacing the dashboardSidebar function with a div function:

      output$sidebarpanel <- renderUI({
        if (USER$Logged == TRUE) { 
          div(
            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"))
            )
          )
        }
      })

Remove also the dashboardBody from the "body" render function:

output$body <- renderUI({
    if (USER$Logged == TRUE) {
      mainpage
    }
    else {
      login
    }
  })

It should fix the problem.

By the way, is it safe to use this kind of login authentication?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!