pub async fn login(pool: &DBPool, email: String, password: String) -> Result<Session> {
        prune_unverified_users(pool).await?;

        let user_exists = user_exists_for_email(pool, email.clone()).await?;

        if user_exists {
            let user = get_user_by_email(pool, email.clone()).await?;

            let password_match = generic_service_err!(
                verify(password, &user.password[..]),
                "Failed to verify password hash");

            if password_match {
                let session = services::session_service::create_session(pool, user.id).await?;
                Ok(session)
            } else {
                Err(Error::new(ErrorKind::Other, "Invalid login"))
            }
        } else {
            Err(Error::new(ErrorKind::Other, "Invalid login"))
        }
    }
/// Logs a user in and returns the new session
/// 
/// # Arguments
/// 
/// * `pool` - The database pool
/// * `email` - The user's email address
/// * `password` - The user's password
Logs a user in and returns the new session
Logs a user in and returns the new session
pub async fn login(pool: &DBPool, email: String, password: String) -> Result<Session> {
        prune_unverified_users(pool).await?;
        let user_exists = user_exists_for_email(pool, email.clone()).await?;
        if user_exists {
            let user = get_user_by_email(pool, email.clone()).await?;
            let password_match = generic_service_err!(
                verify(password, &user.password[..]),
                "Failed to verify password hash");
            if password_match {
                let session = services::session_service::create_session(pool, user.id).await?;
                Ok(session)
            } else {
                Err(Error::new(ErrorKind::Other, "Invalid login"))
            }
        } else {
            Err(Error::new(ErrorKind::Other, "Invalid login"))
        }
    }
pub async fn login ( pool : & DBPool , email : String , password : String ) -> Result < Session > { prune_unverified_users ( pool ) . await ? ; let user_exists = user_exists_for_email ( pool , email . clone ( ) ) . await ? ; if user_exists { let user = get_user_by_email ( pool , email . clone ( ) ) . await ? ; let password_match = generic_service_err ! ( verify ( password user password [ ] ) " " ) ; if password_match { let session = services :: session_service :: create_session ( pool , user . id ) . await ? ; Ok ( session ) } else { Err ( Error :: new ( ErrorKind :: Other , " " ) ) } } else { Err ( Error :: new ( ErrorKind :: Other , " " ) ) } }
Logs a user in and returns the new session
Logs a user in and returns the new session
pool
&DBPool
email
String
password
String
pool
&DBPool
email
String
password
String