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

After upgrading to 2.0, updateF7Login doesn't work! #265

Open
korterling opened this issue Jun 11, 2024 · 2 comments
Open

After upgrading to 2.0, updateF7Login doesn't work! #265

korterling opened this issue Jun 11, 2024 · 2 comments

Comments

@korterling
Copy link

korterling commented Jun 11, 2024

hi ,@DivadNojnarg

I have a code ,it is work in version 1.0;
but after upgrading to 2.0, updateF7Login doesn't work!
can you help me,the code is as follow:

library(shiny)
library(shinyMobile)

ui <- f7Page(
  title = "shinyMobile App",
  f7SingleLayout(
    navbar = f7Navbar(title = "Login Demo"),
    f7Login(
      id = "login",
      title = "Login",
      subtitle = "Please log in to continue",
      footer = tagList(
        f7Link(label = "Forgot password?", href = "#"),
        f7Link(label = "Sign up", href = "#")
      )
    ),
    f7Button(inputId = "login_btn", label = "Log In")
  )
)

server <- function(input, output, session) {
  observeEvent(input$`login-submit`, {
    updateF7Login(
      id = "login",
      session = session,
      user='abc',password='abc',cancel=T
      
    )
  })
}

shinyApp(ui, server)

@DivadNojnarg
Copy link
Member

Hi,

Sorry we made some changes here and you have to come up with your own server logic implementation as a form of module like with myModuleServer defined below. f7Login is the UI module so your custom module must share the same id when you call it (see below).
You can have a look at the f7LoginServer code for inspiration or use it directly but this isn't secured.

library(shiny)
library(shinyMobile)

ui <- f7Page(
  title = "shinyMobile App",
  f7SingleLayout(
    navbar = f7Navbar(title = "Login Demo"),
    f7Login(
      id = "login",
      title = "Login",
      "Please log in to continue",
      footer = tagList(
        f7Link(label = "Forgot password?", href = "#"),
        f7Link(label = "Sign up", href = "#")
      )
    ),
    f7Button(inputId = "login_btn", label = "Log In")
  )
)

myLoginServer <- function(id) {
  moduleServer(
    id,
    function(input, output, session) {
      observeEvent(input$submit, {
        updateF7Login(
          user = 'abc', 
          password = 'abc'
        )
      })
    }
  )
}

server <- function(input, output, session) {
  myLoginServer("login")
}

shinyApp(ui, server)

@korterling
Copy link
Author

korterling commented Jun 12, 2024

@DivadNojnarg thank you very much.
I changed a little bit to understand your code, but this doesn't work anymore,
Where did I go wrong?
the code as bellow:

library(shiny)
library(shinyMobile)

ui <- f7Page(
  title = "shinyMobile App",
  f7SingleLayout(
    navbar = f7Navbar(title = "Login Demo"),
    f7Login(
      id = "login",
      title = "Login",
      "Please log in to continue",
      footer = tagList(
        f7Link(label = "Forgot password?", href = "#"),
        f7Link(label = "Sign up", href = "#")
      )
    ),
    f7Button(inputId = "login_btn", label = "Log In")
  )
)


server <- function(input, output, session) {
  observeEvent(input$`login-submit`, {
    if (input$`login-user` == "abc" && input$`login-password` == "abc") {
    updateF7Login(
      user = 'abc',
      password = 'abc',
      cancel = TRUE
    )
    }
  })
}

shinyApp(ui, server)

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

2 participants