cargo fmt on all that
This commit is contained in:
parent
aa792a0862
commit
8828a9bd86
@ -131,7 +131,8 @@ impl EmailSignup {
|
||||
}
|
||||
|
||||
fn delete_existings_by_email(conn: &DbConn, email: &str) -> Result<usize> {
|
||||
let existing_signups = email_signups::table.filter(email_signups::email.to_lowercase().eq(email.to_lowercase()));
|
||||
let existing_signups = email_signups::table
|
||||
.filter(email_signups::email.to_lowercase().eq(email.to_lowercase()));
|
||||
diesel::delete(existing_signups)
|
||||
.execute(&**conn)
|
||||
.map_err(Error::from)
|
||||
|
@ -23,8 +23,11 @@ const TOKEN_VALIDITY_HOURS: i64 = 2;
|
||||
impl PasswordResetRequest {
|
||||
pub fn insert(conn: &Connection, email: &str) -> Result<String> {
|
||||
// first, delete other password reset tokens associated with this email:
|
||||
let existing_requests =
|
||||
password_reset_requests::table.filter(password_reset_requests::email.to_lowercase().eq(email.to_lowercase()));
|
||||
let existing_requests = password_reset_requests::table.filter(
|
||||
password_reset_requests::email
|
||||
.to_lowercase()
|
||||
.eq(email.to_lowercase()),
|
||||
);
|
||||
diesel::delete(existing_requests).execute(conn)?;
|
||||
|
||||
// now, generate a random token, set the expiry date,
|
||||
|
@ -61,7 +61,7 @@ pub struct User {
|
||||
pub outbox_url: String,
|
||||
pub inbox_url: String,
|
||||
pub summary: String,
|
||||
pub email : Option<String>,
|
||||
pub email: Option<String>,
|
||||
pub hashed_password: Option<String>,
|
||||
pub instance_id: i32,
|
||||
pub creation_date: NaiveDateTime,
|
||||
@ -204,9 +204,9 @@ impl User {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Should create user record with normalized(lowercased) email
|
||||
DONE: Store email case-sensitive but always compare them after lowering
|
||||
*/
|
||||
* TODO: Should create user record with normalized(lowercased) email
|
||||
DONE: Store email case-sensitive but always compare them after lowering
|
||||
*/
|
||||
pub fn email_used(conn: &DbConn, email: &str) -> Result<bool> {
|
||||
use diesel::dsl::{exists, select};
|
||||
|
||||
@ -214,7 +214,7 @@ impl User {
|
||||
select(exists(
|
||||
users::table
|
||||
.filter(users::instance_id.eq(Instance::get_local()?.id))
|
||||
.filter(users::email.to_lowercase().eq(lower_email))
|
||||
.filter(users::email.to_lowercase().eq(lower_email)),
|
||||
))
|
||||
.get_result(&**conn)
|
||||
.map_err(Error::from)
|
||||
|
@ -31,7 +31,11 @@ pub struct EmailSignupForm {
|
||||
}
|
||||
|
||||
fn emails_match(form: &EmailSignupForm) -> Result<(), ValidationError> {
|
||||
if form.email_confirmation.to_lowercase().eq(form.email.to_lowercase()) {
|
||||
if form
|
||||
.email_confirmation
|
||||
.to_lowercase()
|
||||
.eq(form.email.to_lowercase())
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(ValidationError::new("emails_match"))
|
||||
|
Loading…
Reference in New Issue
Block a user