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

Issue with registering a new user when creating a fully custom sign page #227

Open
EmmanuelUgo opened this issue May 8, 2024 · 0 comments

Comments

@EmmanuelUgo
Copy link

Hi guys!

Great package, I came across a small issue while I was creating a custom shiny login page using the {polished} library.

I followed the guide provided here but it doesn’t seem to work well with registering a new user. When I click on the register button, nothing happens.

Here’s a reprex:

library(shiny)
library(polished)


my_custom_sign_in_module_ui <- tagList(
  shinyjs::useShinyjs(),
  # your custom sign in inputs
  
  div(
    id = "sign_in_page",
    email_input("sign_in_email"),
    password_input("sign_in_password"),
    actionButton("sign_in_submit",
                 "Sign In"),
    actionLink("go_to_register",
               "Not a member? Register!")
  ),
  
  # your custom registration inputs.  Your inputs
  shinyjs::hidden(
    div(
      id = "register_page",
      password_input("register_password"),
      password_input("register_password_verify"),
      actionButton("register_submit", "Register"),
      actionLink("go_to_sign_in", "Already a member? Sign in!")
    )
  ),
  
  
  # make sure to call this function somewhere in your sign in page UI.  It loads
  # the JavaScript used in the sign in and registration process.
  sign_in_js()  
)


my_custom_sign_in_module <- function(input, output, session) {
  # your custom sign in and registration server logic
  # We provide an example showing the sign in & registration pages separately
  
  # show the registration inputs & button
  observeEvent(input$go_to_register, {
    shinyjs::hideElement("sign_in_page")
    shinyjs::showElement("register_page")
  })
  
  # show the sign in inputs & button
  observeEvent(input$go_to_sign_in, {
    shinyjs::hideElement("register_page")
    shinyjs::showElement("sign_in_page")
  })
  
  jwt <- reactive({
    # optional: include additional authorization checks here
    input$check_jwt
  })
  
  sign_in_check_jwt(jwt)
}

ui <- secure_ui(ui = fluidPage(h1("I am a Shiny app!")),
                # you must pass "sign_in" sign in to your custom module `id` argument
                # as done below:
                sign_in_page_ui = my_custom_sign_in_module_ui)

server <- secure_server(
  server = function(input, output, session) {
  },
  custom_sign_in_server = my_custom_sign_in_module
)


shinyApp(
  ui,
  server,
  onStart = function() {
    polished_config(
      api_key = "<your polished.tech API key>",
      app_name = "<your app name from polished.tech>"
    )
  }
)

Thanks!

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

1 participant