-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from Tychobra/is_auth_required
new "is_auth_required" option to allow users to access your app with …
- Loading branch information
Showing
8 changed files
with
150 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
library(shiny) | ||
library(polished) | ||
library(config) | ||
library(shinyjs) | ||
|
||
app_config <- config::get() | ||
|
||
# configure polished | ||
global_sessions_config( | ||
app_name = "polished_example_03", | ||
api_key = app_config$api_key, | ||
is_auth_required = FALSE | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
server <- function(input, output, session) { | ||
|
||
output$secure_content <- renderPrint({ | ||
session$userData$user() | ||
}) | ||
|
||
observe({ | ||
|
||
if (is.null(session$userData$user())) { | ||
|
||
hideElement("sign_out") | ||
showElement("go_to_sign_in") | ||
|
||
} else { | ||
|
||
hideElement("go_to_sign_in") | ||
showElement("sign_out") | ||
|
||
} | ||
|
||
}) | ||
|
||
observeEvent(input$sign_out, { | ||
req(session$userData$user()) | ||
|
||
sign_out_from_shiny(session) | ||
session$reload() | ||
|
||
}) | ||
|
||
observeEvent(input$go_to_sign_in, { | ||
|
||
# set query string to sign in page | ||
shiny::updateQueryString( | ||
queryString = paste0("?page=sign_in"), | ||
session = session, | ||
mode = "push" | ||
) | ||
session$reload() | ||
}) | ||
|
||
} | ||
|
||
secure_server(server) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
|
||
ui <- fluidPage( | ||
shinyjs::useShinyjs(), | ||
fluidRow( | ||
column( | ||
6, | ||
h1("Polished Example 03"), | ||
br() | ||
), | ||
column( | ||
6, | ||
br(), | ||
shinyjs::hidden(actionButton( | ||
"sign_out", | ||
"Sign Out", | ||
icon = icon("sign-out-alt"), | ||
class = "pull-right" | ||
)), | ||
shinyjs::hidden(actionButton( | ||
"go_to_sign_in", | ||
"Sign In", | ||
icon = icon("sign-in-alt"), | ||
class = "pull-right" | ||
)) | ||
), | ||
column( | ||
12, | ||
verbatimTextOutput("secure_content") | ||
) | ||
) | ||
) | ||
|
||
secure_ui(ui) |