upsert_user_verification

Function upsert_user_verification 

Source
pub async fn upsert_user_verification(
    tracking_label: &str,
    user_id: i32,
    email: &str,
    is_new_user: bool,
    verified: i32,
    conn: &PooledConnection<'_, PostgresConnectionManager<MakeTlsConnector>>,
) -> Result<String, String>
Expand description

upsert_user_verification

Upsert the user’s users_verified record in the db and insert/update the user email verification token value. Also set the users_verified.exp_date to an expiration date in future (Utc) based off the environment variable USER_EMAIL_VERIFICATION_EXP_IN_SECONDS.

§Usage

§Environment Variables

Email verification expiration date can be changed with

# 1 second
export USER_EMAIL_VERIFICATION_EXP_IN_SECONDS=1
# 30 days
export USER_EMAIL_VERIFICATION_EXP_IN_SECONDS=2592000

§Arguments

  • tracking_label - &str - caller logging label
  • user_id - i32 - user id
  • email - &str - email address
  • is_new_user - bool - flag to allow skipping updating the users.email
  • verified - i32 - change the email verification with default unverified (1) and verified (1)
  • conn - PooledConnection - an established db connection from the postgres client db threadpool

§Returns

§upsert_user_verification on Success Returns

Ok(String)

§Errors

§upsert_user_verification on Failure Returns

Err(String)