diff --git a/DESCRIPTION b/DESCRIPTION index 8c992b5..3c7ad17 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: learnitdown Type: Package -Version: 1.5.1 +Version: 1.5.2 Title: 'SciViews' - R Markdown, Bookdown and Learnr Additions for Learning Material Description: Extension to R Markdown, Bookdown and Learnr for building better learning and e-learning material: H5P integration, course-contextual divs, @@ -12,7 +12,7 @@ Maintainer: Philippe Grosjean Depends: R (>= 3.0.0) Imports: glue, magick, webshot, rstudioapi, shiny, shinylogs, shinytoastr, mongolite, jsonlite, later, utils, learnr, gradethis, httr, remotes, PKI, - knitr, testthat, httpuv, getPass, stats + knitr, testthat, httpuv, keyring, getPass, stats Suggests: covr, rmarkdown, spelling Remotes: rstudio/learnr@802e4ec, rstudio/gradethis@v0.2.8.9000 License: GPL (>=2) diff --git a/NAMESPACE b/NAMESPACE index ce9bbcc..c88341b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -67,6 +67,8 @@ importFrom(jsonlite,base64_dec) importFrom(jsonlite,base64_enc) importFrom(jsonlite,fromJSON) importFrom(jsonlite,toJSON) +importFrom(keyring,key_get) +importFrom(keyring,key_set_with_value) importFrom(learnr,answer) importFrom(learnr,run_tutorial) importFrom(learnr,tutorial_options) diff --git a/NEWS.md b/NEWS.md index a1f65fd..ea81028 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# learnitdown 1.5.2 + +- The dependency to {keyring} is added again. It allows to store the password + # learnitdown 1.5.1 - {learnr} and {gradethis} upgraded to higher versions. diff --git a/R/config.R b/R/config.R index a4ffab5..f761c53 100644 --- a/R/config.R +++ b/R/config.R @@ -338,12 +338,12 @@ ref1 = NULL, ref2 = NULL) { return(pass) # Otherwise, try getting it from keyring -# if (!isTRUE(reset) && nchar(key)) { -# pass <- try(key_get(service = "org.sciviews.learnitdown", -# username = key), silent = TRUE) -# if (!inherits(pass, "try-error")) -# return(pass) -# } + if (!isTRUE(reset) && nchar(key)) { + pass <- try(key_get(service = "org.sciviews.learnitdown", + username = key), silent = TRUE) + if (!inherits(pass, "try-error")) + return(pass) + } # Ultimately, ask for it... (only in interactive mode) if (interactive()) @@ -362,15 +362,15 @@ ref1 = NULL, ref2 = NULL) { } # If the password and key are not blank, store it in keyring -# if (nchar(pass) && nchar(key)) { -# res <- try(key_set_with_value(service = "org.sciviews.learnitdown", -# username = key, password = pass), silent = TRUE) # We prefer no error -# # message in case it does not work (then we just will have to provide the -# # password every time we need it) -# if (inherits(res, "try-error")) { -# warning("The password cannot be stored in the keyring backend") -# attr(pass, "error") <- res -# } -# } + if (nchar(pass) && nchar(key)) { + res <- try(key_set_with_value(service = "org.sciviews.learnitdown", + username = key, password = pass), silent = TRUE) # We prefer no error + # message in case it does not work (then we just will have to provide the + # password every time we need it) + if (inherits(res, "try-error")) { + warning("The password cannot be stored in the keyring backend") + attr(pass, "error") <- res + } + } pass } diff --git a/R/learnitdown-package.R b/R/learnitdown-package.R index c0e99e5..6f0d0f4 100644 --- a/R/learnitdown-package.R +++ b/R/learnitdown-package.R @@ -23,7 +23,7 @@ #' @importFrom PKI PKI.digest PKI.decrypt PKI.encrypt #' @importFrom getPass getPass #' @importFrom stats runif -#importFrom keyring key_set_with_value key_get +#' @importFrom keyring key_set_with_value key_get # The following block is used by usethis to automatically manage # roxygen namespace tags. Modify with care! ## usethis namespace: start