Skip to content

Commit

Permalink
fix: req signout check pre-signout #75
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCoene committed Nov 29, 2023
1 parent 6154e98 commit beebc4a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
14 changes: 9 additions & 5 deletions R/class-auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ FirebaseAuth <- R6::R6Class(
req_sign_out = function(){
user <- private$get_signed_in_checked()
private$.user_signed_in <- user

if(length(user$success))
return(FALSE)

req(!user$success)
},
#' @details Set language code for auth provider
Expand Down Expand Up @@ -287,10 +291,10 @@ FirebaseAuth <- R6::R6Class(

}

now <- as.numeric(Sys.time() + private$.grace_period)
now <- as.numeric(Sys.time() + private$.grace_period)

if(as.numeric(signature$exp) < now){
cli_alert_danger("Signature expiry is in the past")
if(as.numeric(signature$exp) < now){
cli_alert_danger("Signature expiry is in the past")
if(interactive){
CHOICE <- menu(c("Yes", "No"), title="Do you still want to continue ?")
if (CHOICE != TRUE){
Expand All @@ -303,8 +307,8 @@ FirebaseAuth <- R6::R6Class(
}
}

if(as.numeric(signature$iat) > now){
cli_alert_danger("Signature expiry is in the future")
if(as.numeric(signature$iat) > now){
cli_alert_danger("Signature expiry is in the future")
if(interactive){
CHOICE <- menu(c("Yes", "No"), title="Do you still want to continue ?")
if (CHOICE != TRUE){
Expand Down
44 changes: 22 additions & 22 deletions R/class-core.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#'
#' @export
Firebase <- R6::R6Class(
"Firebase",
public = list(
"Firebase",
public = list(
session = NULL,
#' @details Initialise Firebase
#'
Expand All @@ -19,24 +19,24 @@ Firebase <- R6::R6Class(
#' @param session A valid shiny session.
#'
#' @return Invisibly return the class.
initialize = function(
initialize = function(
config_path = "firebase.rds",
session = shiny::getDefaultReactiveDomain()
){
session = shiny::getDefaultReactiveDomain()
){

conf <- read_config(config_path)
conf <- read_config(config_path)
self$session <- session
private$.unique_id <- create_unique_id()
private$.conf <- conf
private$.project_id <- conf$projectId

# namespace
private$.namespace(session)
private$.send(
"initialize-core",
private$.send(
"initialize-core",
conf = conf
)
},
)
},
#' @details Expose App
#'
#' Expose the `firebaseApp` object product of `initializeApp()` by
Expand All @@ -49,23 +49,23 @@ Firebase <- R6::R6Class(
print = function(){
cli_rule("Firebase")
}
),
private = list(
),
private = list(
send = function(func, msg = list()){
func <- paste0("fireblaze-", func)
msg$ns <- private$.ns
self$session$sendCustomMessage(func, msg)
},
.send = function(func, ...){
func <- paste0("fireblaze-", func)
msg <- list(
ns = private$.ns,
...
)
msg <- list(
ns = private$.ns,
...
)
self$session$sendCustomMessage(func, msg)
},
.render_deps = function(deps){
private$.send('render-dependencies', deps = deps)
private$.send("render-dependencies", deps = deps)
},
get_input = function(name){
name <- paste0("fireblaze_", name)
Expand All @@ -85,9 +85,9 @@ Firebase <- R6::R6Class(
get_project_id = function() {
return(invisible(private$.project_id))
},
.unique_id = NULL,
.ns = "",
.project_id = NULL,
.conf = list()
)
.unique_id = NULL,
.ns = "",
.project_id = NULL,
.conf = list()
)
)
6 changes: 3 additions & 3 deletions R/class-social.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ FirebaseSocial <- R6::R6Class(
#' @param language_code Sets the language to use for the UI.
#' Supported languages are listed [here](https://github.com/firebase/firebaseui-web/blob/master/LANGUAGES.md).
#' Set to `browser` to use the default browser language of the user.
initialize = function(
initialize = function(
persistence = c("session", "local", "memory"),
config_path = "firebase.rds",
language_code = NULL,
session = shiny::getDefaultReactiveDomain()
){
){
super$initialize(
persistence,
config_path,
Expand All @@ -67,7 +67,7 @@ FirebaseSocial <- R6::R6Class(
super$.render_deps(
list(firebase_dep_social())
)
},
},
#' @details Define the scope to request from Google.
#' @param scope Google scope.
#' @return self
Expand Down

0 comments on commit beebc4a

Please sign in to comment.