Ok(base64)
}
+/// Checks the password length
+pub(crate) fn password_length_check(pass: &str) -> Result<(), LemmyError> {
+ if pass.len() > 60 {
+ Err(ApiError::err("invalid_password").into())
+ } else {
+ Ok(())
+ }
+}
+
#[cfg(test)]
mod tests {
use crate::captcha_espeak_wav_base64;
get_user_from_jwt,
get_user_from_jwt_opt,
is_admin,
+ password_length_check,
Perform,
};
use actix_web::web::Data;
}
}
- // Password length check
- if data.password.len() > 60 {
- return Err(ApiError::err("invalid_password").into());
- }
+ password_length_check(&data.password)?;
// Make sure passwords match
if data.password != data.password_verify {
Some(new_password) => {
match &data.new_password_verify {
Some(new_password_verify) => {
+ password_length_check(&new_password)?;
+
// Make sure passwords match
if new_password != new_password_verify {
return Err(ApiError::err("passwords_dont_match").into());
})
.await??;
+ password_length_check(&data.password)?;
+
// Make sure passwords match
if data.password != data.password_verify {
return Err(ApiError::err("passwords_dont_match").into());