R/get_user_by_email.R

Defines functions get_user_by_email

Documented in get_user_by_email

#' get user by email address for the API
#'
#' This is a modification of \code{polished::get_user_by_email} to also query
#' only for users that were created by this polished.tech API account.
#'
#' @param conn the database connection
#' @param email the user's email address
#' @param account_uid the account that created the user
#' @param schema the database schema
#'
#' @return a list of user info if the user is found or `NULL`
#'
#' @export
#'
#' @importFrom pool dbGetQuery
#'
get_user_by_email <- function(conn, email, account_uid, schema = "polished") {

  pool::dbGetQuery(
    conn,
    paste0("SELECT * FROM ", schema, ".users WHERE account_uid=$1 AND email=$2"),
    params = list(
      account_uid,
      email
    )
  )
}
Tychobra/polishedapi documentation built on July 19, 2020, 11:41 p.m.