How to create a login page in shiny?
<p>The goal is to have a shiny module <code>ui1.R</code> that loads a second module <code>ui2.R</code> when the button <code>confirm</code> is clicked. I think the issue is that <code>is.null(input$confirm)</code> is always invalidated. What I need instead, is to invalidate the expression only once <code>confirm</code> is clicked.
The question is very close to <a href="https://stackoverflow.com/questions/28987622/starting-shiny-app-after-password-input">Starting Shiny app after password input</a>, but I am trying to modularize the solution.</p>

<p><strong>ui.R</strong></p>

<pre><code>library(shiny)
library(shinyjs)
htmlOutput("page")
</code></pre>

<p><strong>server.R</strong></p>

<pre><code>rm(list = ls())
library(shiny)
library(dplyr)
library(shinyjs)
Logged &lt;-  FALSE

shinyServer(function(input, output) {

  source('ui1.R') #login page
  source('ui2.R')


  observeEvent(!is.null(input$confirm), {
    Logged &lt;&lt;- T
  })

  observe({
    if (Logged == FALSE) {
      output$page &lt;- renderUI({ 
        ui1Output('ui1Output') 
      })
      output$lsuId &lt;- renderText({ input$lsuId })
    }
    if (Logged == TRUE) 
    {
      output$page &lt;- renderUI({ ui2 })
    }
  })
  callModule(ui1,'ui1') 
})
</code></pre>

<p><strong>ui1.R</strong></p>

<pre><code>library(shinyjs)

ui1Output &lt;-  function(id, label = "ui1") {
  ns &lt;- NS(id)
  shinyUI(fluidPage(
    useShinyjs(),
    titlePanel("Form"),
    div(textInput(ns("lsuId"), "This has to be filled", ""),
      actionButton(ns("confirm"), "Submit", class = "btn-primary")
    )
  ))
}

ui1 &lt;- function(input, output, session) {
  observe({
    LSUID &lt;- reactive({ input$lsuId })
    shinyjs::toggleState(id = "confirm", condition = LSUID())
  })
}
</code></pre>

<p><strong>ui2.R</strong></p>

<pre><code>ui2&lt;-  shinyUI(fluidPage(
 div("well done!")
))
</code></pre>

<p><strong>global.R</strong></p>

<pre><code>source('ui1.R') #login page
source('ui2.R')
</code></pre>