Comments (5)
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.
Yes, that's what I ended up doing. Thanks for the response!
from shinyauthr.
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.
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.
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)
- Additional info in the login box HOT 2
- Background and text colour HOT 1
- Issue adding a loading icon/spinner HOT 1
- live example app down? HOT 3
- CRAN submission HOT 3
- How to enable password coding by setting "sodium_hashed" parameter? HOT 2
- Reload session when logging out? HOT 14
- Error object 'js' not found HOT 8
- Error in shiny::isTruthy: attempt to apply non-function HOT 2
- Option to bypass/deactivate the login
- Error: shinyjs: Error parsing the JavaScript code provided. HOT 1
- shinydashboard shows app without login using shinyauthr HOT 1
- White font color on login button is difficult to see HOT 3
- login error after shiny timeout HOT 4
- Beautify the login window suggestion HOT 3
- Where should I put the data for my own app in shinyboard? HOT 1
- Cases for help HOT 2
- Using shinyauthr with shiny rmarkdown documents HOT 1
- Log password failures HOT 1
- Possible to call a database rather than download entire user base? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shinyauthr.