Giter VIP home page Giter VIP logo

Comments (5)

PaulC91 avatar PaulC91 commented on June 12, 2024 3

No, shinyauthr::loginServer (previously shinyauthr::login) won't work with a reactive data object, so you'd need to load your user base inside your server function and then reload the session after the user base has changed to retrieve the updated user base.

You could build this into a change password process by adding session$reload() at the end. This will log out the user and they can then log in again with their new password, which I think is quite a normal UX procedure for password changes.

from shinyauthr.

KryeKuzhinieri avatar KryeKuzhinieri commented on June 12, 2024 1

Yes, that's what I ended up doing. Thanks for the response!

from shinyauthr.

PaulC91 avatar PaulC91 commented on June 12, 2024

You can't overwrite data inside a reactive like that. But you wouldn't want to because this would only change the password for the duration of their session then it would revert to whatever the password was in the user base your app reads in.

If you want this to be a permanent change you'll need to store your user base data in some form of remote data storage system (sql db, google sheet etc) that is readable and writable from your app. You could then have code that overwrites the pwd for that user on the database at their request, so when they next login and the app reads in your user base data with updated passwords.

from shinyauthr.

AndreasPhilippi avatar AndreasPhilippi commented on June 12, 2024

Hi Paul, thanks for your answer and sry for the missing code-formating in the previous comment.
I have my user data in a database on my server and I can change the password out of the UI. My only problem is that I'm not able to update the user base during the session. I also tried to make the user base reactive as you can see in the following code snipe. But that also dosen't work out for me.
Is there any way to get that done?

# initialise pool objekt when running the App
pool <<- dbPool(
    drv = RMySQL::MySQL(),
    dbname = "mydb",
    host = "XXXXXXX",
    username = "shinyApp",
    password = "XXXXX")

# Server Code snipe
values <- reactiveValues()
values$trigger_user_base = TRUE

# trigger user_base with reactiveValue to get it initialised
user_base <- reactive({
  if(values$trigger_user_base){
    #read user data from database 
    pool%>%
      dbReadTable('user_data')%>%
      select(user,password,permissions,name)
      values$trigger_user_base = FALSE
  }
})

credentials <- callModule(shinyauthr::login, 
                          id = "login", 
                          data = reactive(user_base()),
                          user_col = user,
                          pwd_col = password,
                          log_out = reactive(logout_init())

observeEvent(input$changePW,{
  #change pw in database
  sql <- "UPDATE login_data SET password=?password WHERE name=credentials()$info$name";
  query <- sqlInterpolate(pool, sql, password = input$neupasswort1)
  dbGetQuery(pool, query)

  # trigger user_base
  values$trigger_user_base <- TRUE
})
)```

from shinyauthr.

KryeKuzhinieri avatar KryeKuzhinieri commented on June 12, 2024

Is there any solution to this? Is it possible to update the user base table within the session without having to restart it?

from shinyauthr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.