Skip to content

Commit

Permalink
launch app with empty dataset on successful login
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrue committed Apr 8, 2024
1 parent 7ec5bd2 commit a9fe894
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
14 changes: 8 additions & 6 deletions R/iSEEindex.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,23 @@ iSEElogin <- function(app.title = NULL) {
#' @author Kevin Rue-Albrecht
#'
#' @importFrom utils capture.output
#' @importFrom shiny incProgress markdown modalDialog p showModal
#' showNotification withProgress
#' @importFrom shiny incProgress showNotification withProgress
#' @importFrom shinyjs enable
#'
#' @rdname INTERNAL_launch_isee
.launch_isee <- function(FUN, session, pObjects) {
.launch_isee <- function(FUN, session, pObjects, username, password) {
# nocov start
initial <- NULL # TODO
tour <- NULL # TODO
withProgress(message = sprintf("Logging in ..."),
value = 0, max = 2, {
value = 0, max = 3, {
incProgress(1, detail = "Verifying credentials")
Sys.sleep(2)
se2 <- try(iseelogin) # TODO
if (is(se2, "try-error")) {
if (!.authenticate(username, password)) {
showNotification("Login failed.", type="error")
} else {
incProgress(1, detail = "Loading data set")
se2 <- SummarizedExperiment() # TODO: load desired data set (or another landing page like iSEEindex)
incProgress(1, detail = "Launching iSEE app")
FUN(SE=se2, INITIAL=initial, TOUR=tour)
shinyjs::enable(iSEE:::.generalOrganizePanels) # organize panels
Expand Down
22 changes: 12 additions & 10 deletions R/observers.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#'
#' @rdname INTERNAL_create_observers
.create_observers <- function(input, session, pObjects, rObjects) {

invisible(NULL)
invisible(NULL)
}

#' @param FUN A function to initialize the \pkg{iSEE} observer
Expand All @@ -32,12 +32,14 @@
#'
#' @rdname INTERNAL_create_observers
.create_launch_observers <- function(FUN, input, session, pObjects) {

# nocov start
observeEvent(input[[.ui_login_submit]], {
.launch_isee(FUN, session, pObjects)
}, ignoreNULL=TRUE, ignoreInit=TRUE)
# nocov end

invisible(NULL)

# nocov start
observeEvent(input[[.ui_login_submit]], {
username <- input[[.ui_login_username]]
password <- input[[.ui_login_password]]
.launch_isee(FUN, session, pObjects, username, password)
}, ignoreNULL=TRUE, ignoreInit=TRUE)
# nocov end

invisible(NULL)
}
8 changes: 8 additions & 0 deletions R/utils-authenticate.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.authenticate <- function(username, password) {
authorised_file <- system.file(package = "iSEElogin", "authorized")
authorised_info <- read.table(authorised_file, col.names = c("username", "password"))
any(
username == authorised_info$username &
digest(password, "sha512") == authorised_info$password
)
}
2 changes: 2 additions & 0 deletions inst/authorized
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
testuser 88d89fa7e0441e6118d3769140efb8d23ae897920d4dcb8cb4d48e8e3a96ace3e10245eb99eac499a33498d8a232fd1f45a1627c3937c9bcca5b5072936cb22d
wronguser nevergonnamatch

0 comments on commit a9fe894

Please sign in to comment.