PaulC91 / shinyauthr

R package with shiny authentication modules
https://paulc91.github.io/shinyauthr/
Other
428 stars 81 forks source link

Possible to call a database rather than download entire user base? #68

Closed simitpatel closed 9 months ago

simitpatel commented 9 months ago

It seems like right now I need to have a dataframe of users and their passwords that the login form validates against. Is it possible instead to have the form check with a database, so that I don't have to download the user base in the app beforehand?

PaulC91 commented 9 months ago

No you won't being able to check directly on a database but you can pull your user base table into an R dataframe on app launch and use that, you don't have to store it in a local file so there shouldn't be any security issues. Or is your user base table too big to fit into memory?

simitpatel commented 9 months ago

The issue I am having is that the shiny app I built allows for self-registration. But if a user registers, they need to refresh the page before logging in, otherwise their new user info will not be in the database. Does that make sense? Is there a way around this problem?

On Thu, Feb 29, 2024, 5:13 AM Paul Campbell @.***> wrote:

No you won't being able to check directly on a database but you can pull your user base table into an R dataframe on app launch and use that, you don't have to store it in a local file so there shouldn't be any security issues. Or is your user base table too big to fit into memory?

— Reply to this email directly, view it on GitHub https://github.com/PaulC91/shinyauthr/issues/68#issuecomment-1970814578, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB7UGOOYJ7KCJKWAIE26IRDYV37K5AVCNFSM6AAAAABD65EU7KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZQHAYTINJXHA . You are receiving this because you authored the thread.Message ID: @.***>

PaulC91 commented 9 months ago

Ah ok yes I see the use case. I just merged a PR that allows for reactive data to be used as the user base. This means you can now use a function like shiny::reactivePoll to re-read in your user table from the database whenever a new user has been added and pass this reactive data to shinyauthr::loginServer (without the parenthesis). Let me know if that works for you. You'll need to re-install the package from github to get the latest dev version.

simitpatel commented 9 months ago

paul, thank you so much! this is awesome! works like a charm!

i'm closing this issue in the interest of github cleanliness -- if that's not preferred, feel free to reverse and/or let me know!