Skip to content

Commit

Permalink
keyring added again
Browse files Browse the repository at this point in the history
  • Loading branch information
phgrosjean committed Sep 16, 2022
1 parent 37f92bf commit c3e5866
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -12,7 +12,7 @@ Maintainer: Philippe Grosjean <[email protected]>
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/[email protected]
License: GPL (>=2)
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
32 changes: 16 additions & 16 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion R/learnitdown-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c3e5866

Please sign in to comment.