check if an account is activated before allowing a login
This commit is contained in:
parent
2351b31125
commit
0db9a73849
@ -39,6 +39,7 @@ pub struct UserAccountEntity {
|
||||
pub muted_until: Option<chrono::DateTime<chrono::Utc>>,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
pub flags: u32, // TODO: is this used for anything other than character creation?
|
||||
pub activated: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -25,6 +25,7 @@ pub struct PgUserAccount {
|
||||
muted: Option<chrono::DateTime<chrono::Utc>>,
|
||||
created_at: chrono::DateTime<chrono::Utc>,
|
||||
flags: i32,
|
||||
activated: bool,
|
||||
}
|
||||
|
||||
impl Into<UserAccountEntity> for PgUserAccount {
|
||||
@ -37,9 +38,9 @@ impl Into<UserAccountEntity> for PgUserAccount {
|
||||
muted_until: self.muted,
|
||||
created_at: self.created_at,
|
||||
flags: self.flags as u32,
|
||||
// TOOD
|
||||
guildcard: self.id as u32 + 1,
|
||||
team_id: None,
|
||||
activated: self.activated
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,21 +15,25 @@ pub async fn validate_login<EG: EntityGateway>(id: ClientId,
|
||||
-> Result<Vec<SendShipPacket>, ShipError> {
|
||||
Ok(match get_login_status(entity_gateway, pkt).await {
|
||||
Ok(user) => {
|
||||
let mut response = LoginResponse::by_status(AccountStatus::Ok, Session::new());
|
||||
response.guildcard = user.id.0 as u32;
|
||||
response.team_id = user.team_id.map_or(31, |ti| ti) as u32;
|
||||
let characters = entity_gateway.get_characters_by_user(&user).await;
|
||||
let character = characters
|
||||
.get(pkt.session.character_slot as usize)
|
||||
.ok_or(ShipError::InvalidSlot(id, pkt.session.character_slot as u32))?.as_ref()
|
||||
.ok_or(ShipError::NoCharacterInSlot(id, pkt.session.character_slot as u32))?
|
||||
.clone();
|
||||
let settings = entity_gateway.get_user_settings_by_user(&user).await
|
||||
.ok_or(ShipError::ClientNotFound(id))?;
|
||||
if user.activated {
|
||||
let mut response = LoginResponse::by_status(AccountStatus::Ok, Session::new());
|
||||
response.guildcard = user.id.0 as u32;
|
||||
response.team_id = user.team_id.map_or(31, |ti| ti) as u32;
|
||||
let characters = entity_gateway.get_characters_by_user(&user).await?;
|
||||
let character = characters
|
||||
.get(pkt.session.character_slot as usize)
|
||||
.ok_or(ShipError::InvalidSlot(id, pkt.session.character_slot as u32))?.as_ref()
|
||||
.ok_or(ShipError::NoCharacterInSlot(id, pkt.session.character_slot as u32))?
|
||||
.clone();
|
||||
let settings = entity_gateway.get_user_settings_by_user(&user).await?;
|
||||
|
||||
item_manager.load_character(entity_gateway, &character).await;
|
||||
clients.insert(id, ClientState::new(user, settings, character, pkt.session));
|
||||
vec![SendShipPacket::LoginResponse(response), SendShipPacket::ShipBlockList(ShipBlockList::new(&&ship_name, 3))]
|
||||
item_manager.load_character(entity_gateway, &character).await;
|
||||
clients.insert(id, ClientState::new(user, settings, character, pkt.session));
|
||||
vec![SendShipPacket::LoginResponse(response), SendShipPacket::ShipBlockList(ShipBlockList::new(&&ship_name, 3))]
|
||||
}
|
||||
else {
|
||||
vec![SendShipPacket::LoginResponse(LoginResponse::by_status(AccountStatus::Locked, Session::new()))]
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
vec![SendShipPacket::LoginResponse(LoginResponse::by_status(err, Session::new()))]
|
||||
|
Loading…
x
Reference in New Issue
Block a user