Compare commits
2 commits
c2e28c3791
...
b8a338d9ba
Author | SHA1 | Date | |
---|---|---|---|
b8a338d9ba | |||
39dfa6816e |
2 changed files with 5 additions and 2 deletions
|
@ -15,6 +15,7 @@ mod process;
|
||||||
pub mod db;
|
pub mod db;
|
||||||
mod email;
|
mod email;
|
||||||
|
|
||||||
|
use std::env;
|
||||||
use std::string::ToString;
|
use std::string::ToString;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::{AtomicI64, AtomicU64, Ordering};
|
use std::sync::atomic::{AtomicI64, AtomicU64, Ordering};
|
||||||
|
@ -36,6 +37,8 @@ pub static SMTP_URL: Lazy<String> = Lazy::new(|| std::env::var("SMTP_URL").expec
|
||||||
pub static SMTP_USERNAME: Lazy<String> = Lazy::new(|| std::env::var("SMTP_USERNAME").expect("NO SMTP_USERNAME DEFINED"));
|
pub static SMTP_USERNAME: Lazy<String> = Lazy::new(|| std::env::var("SMTP_USERNAME").expect("NO SMTP_USERNAME DEFINED"));
|
||||||
pub static SMTP_PASSWORD: Lazy<String> = Lazy::new(|| std::env::var("SMTP_PASSWORD").expect("NO SMTP_PASSWORD DEFINED"));
|
pub static SMTP_PASSWORD: Lazy<String> = Lazy::new(|| std::env::var("SMTP_PASSWORD").expect("NO SMTP_PASSWORD DEFINED"));
|
||||||
|
|
||||||
|
pub static AUTH_URL: Lazy<String> = Lazy::new(|| std::env::var("AUTH_URL").unwrap_or("https://auth.asklyphe.com".to_string()));
|
||||||
|
|
||||||
pub static PROCESSES_HANDLED: AtomicU64 = AtomicU64::new(0);
|
pub static PROCESSES_HANDLED: AtomicU64 = AtomicU64::new(0);
|
||||||
pub static LAST_MESSAGE: AtomicI64 = AtomicI64::new(0);
|
pub static LAST_MESSAGE: AtomicI64 = AtomicI64::new(0);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ use crate::db::{invite_code, session, user};
|
||||||
use crate::db::invite_code::ConsumeInviteCodeError;
|
use crate::db::invite_code::ConsumeInviteCodeError;
|
||||||
use crate::db::session::{CreateSessionError, DeleteSessionError, FetchSessionError};
|
use crate::db::session::{CreateSessionError, DeleteSessionError, FetchSessionError};
|
||||||
use crate::db::user::{CreateUserError, DeleteUserError, EmailChangeError, FetchUserError, RegisterVerificationCodeError, VerifyEmailPassComboError, VerifyVerificationCodeError};
|
use crate::db::user::{CreateUserError, DeleteUserError, EmailChangeError, FetchUserError, RegisterVerificationCodeError, VerifyEmailPassComboError, VerifyVerificationCodeError};
|
||||||
use crate::email;
|
use crate::{email, AUTH_URL};
|
||||||
|
|
||||||
fn generate_email_verification_code() -> String {
|
fn generate_email_verification_code() -> String {
|
||||||
rand::thread_rng()
|
rand::thread_rng()
|
||||||
|
@ -121,7 +121,7 @@ pub async fn register_request(db: &DatabaseConnection, request: RegisterRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("verification code for {} is \"{}\"", request.username, verification_code);
|
debug!("verification code for {} is \"{}\"", request.username, verification_code);
|
||||||
email::send_verification_code_email(&request.email, &request.username, format!("https://auth.asklyphe.com/verify?username={}&token={}", request.username, verification_code).as_str());
|
email::send_verification_code_email(&request.email, &request.username, format!("{}/verify?username={}&token={}", AUTH_URL.as_str(), request.username, verification_code).as_str());
|
||||||
|
|
||||||
RegisterResponse::Success
|
RegisterResponse::Success
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue