#' get invite
#'
#' @param conn the database connection
#' @param account_uid the uid of the account
#' @param app_uid the id of the app
#' @param user_uid the user uid
#' @param schema the name of the schema
#'
#' @return if the user does not have an invite, an empty list. If the user has
#' an invite, a list with the following elements:
#' - user_uid
#' - email
#' - is_admin
#' - created_at
#'
#' @importFrom pool dbGetQuery
#'
#' @export
#'
get_invite <- function(conn, account_uid, app_uid, user_uid, schema = "polished") {
invite <- pool::dbGetQuery(
conn,
paste0("SELECT user_uid, is_admin, created_at FROM ", schema, ".app_users WHERE account_uid=$1 AND user_uid=$2 AND app_uid=$3"),
params = list(
account_uid,
user_uid,
app_uid
)
)
if (identical(nrow(invite), 1L)) {
email <- pool::dbGetQuery(
conn,
paste0("SELECT email FROM ", schema, ".users WHERE uid=$1 AND account_uid=$2"),
list(
invite$user_uid,
account_uid
)
)$email
out <- list(
user_uid = invite$user_uid,
email = email,
is_admin = invite$is_admin,
created_at = invite$created_at
)
} else {
out <- list()
}
out
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.