fix: don't interrupt login if error getting character info
This commit is contained in:
parent
12741c0c33
commit
e0683e1036
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use chrono::{Duration, Utc};
|
use chrono::{Duration, Utc};
|
||||||
use lodestone_scraper::LodestoneScraper;
|
use lodestone_scraper::LodestoneScraper;
|
||||||
use log::trace;
|
use log::{trace, warn};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use crate::{AuthenticateRequest, AuthenticateResponse, ClientState, State, User, util, World, WsStream};
|
use crate::{AuthenticateRequest, AuthenticateResponse, ClientState, State, User, util, World, WsStream};
|
||||||
|
@ -34,8 +34,10 @@ pub async fn authenticate(state: Arc<RwLock<State>>, client_state: Arc<RwLock<Cl
|
||||||
if Utc::now().naive_utc().signed_duration_since(user.last_updated) >= Duration::hours(2) {
|
if Utc::now().naive_utc().signed_duration_since(user.last_updated) >= Duration::hours(2) {
|
||||||
let info = LodestoneScraper::default()
|
let info = LodestoneScraper::default()
|
||||||
.character(user.lodestone_id as u64)
|
.character(user.lodestone_id as u64)
|
||||||
.await
|
.await;
|
||||||
.context("could not get character info")?;
|
|
||||||
|
match info {
|
||||||
|
Ok(info) => {
|
||||||
let world_name = info.world.as_str();
|
let world_name = info.world.as_str();
|
||||||
|
|
||||||
user.name = info.name.clone();
|
user.name = info.name.clone();
|
||||||
|
@ -52,6 +54,11 @@ pub async fn authenticate(state: Arc<RwLock<State>>, client_state: Arc<RwLock<Cl
|
||||||
.await
|
.await
|
||||||
.context("could not update user")?;
|
.context("could not update user")?;
|
||||||
}
|
}
|
||||||
|
Err(e) => {
|
||||||
|
warn!("could not get character info during login: {:#?}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let world = World::from_str(&user.world).map_err(|_| anyhow::anyhow!("invalid world in db"))?;
|
let world = World::from_str(&user.world).map_err(|_| anyhow::anyhow!("invalid world in db"))?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user