2024-02-29 14:12:45 +00:00
|
|
|
use lemmy_db_views::structs::{LocalUserView, SiteView};
|
|
|
|
use lemmy_utils::{error::LemmyResult, LemmyErrorType};
|
|
|
|
|
2023-07-28 14:39:38 +00:00
|
|
|
pub mod add_admin;
|
|
|
|
pub mod ban_person;
|
|
|
|
pub mod block;
|
|
|
|
pub mod change_password;
|
|
|
|
pub mod change_password_after_reset;
|
2023-09-20 14:49:54 +00:00
|
|
|
pub mod generate_totp_secret;
|
2023-07-28 14:39:38 +00:00
|
|
|
pub mod get_captcha;
|
|
|
|
pub mod list_banned;
|
2023-10-09 10:46:12 +00:00
|
|
|
pub mod list_logins;
|
2023-07-28 14:39:38 +00:00
|
|
|
pub mod login;
|
2023-10-09 10:46:12 +00:00
|
|
|
pub mod logout;
|
2023-07-28 14:39:38 +00:00
|
|
|
pub mod notifications;
|
|
|
|
pub mod report_count;
|
|
|
|
pub mod reset_password;
|
|
|
|
pub mod save_settings;
|
2023-09-20 14:49:54 +00:00
|
|
|
pub mod update_totp;
|
2023-10-17 15:25:48 +00:00
|
|
|
pub mod validate_auth;
|
2023-07-28 14:39:38 +00:00
|
|
|
pub mod verify_email;
|
2024-02-29 14:12:45 +00:00
|
|
|
|
|
|
|
/// Check if the user's email is verified if email verification is turned on
|
|
|
|
/// However, skip checking verification if the user is an admin
|
|
|
|
fn check_email_verified(local_user_view: &LocalUserView, site_view: &SiteView) -> LemmyResult<()> {
|
|
|
|
if !local_user_view.local_user.admin
|
|
|
|
&& site_view.local_site.require_email_verification
|
|
|
|
&& !local_user_view.local_user.email_verified
|
|
|
|
{
|
|
|
|
Err(LemmyErrorType::EmailNotVerified)?
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|