validator_time: &chrono::NaiveDateTime,
claims: &Claims,
) -> Result<(), LemmyError> {
- let user_validation_time = validator_time.timestamp_millis() / 1000;
+ let user_validation_time = validator_time.timestamp();
if user_validation_time > claims.iat {
Err(ApiError::err("not_logged_in").into())
} else {
use crate::settings::structs::Settings;
+use chrono::Utc;
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation};
use serde::{Deserialize, Serialize};
let my_claims = Claims {
sub: local_user_id,
iss: Settings::get().hostname(),
- iat: chrono::Utc::now().timestamp_millis() / 1000,
+ iat: Utc::now().timestamp(),
};
encode(
&Header::default(),
};
use anyhow::{anyhow, Context};
use deser_hjson::from_str;
+use log::warn;
use merge::Merge;
use std::{env, fs, io::Error, net::IpAddr, sync::RwLock};
lazy_static! {
static ref SETTINGS: RwLock<Settings> = RwLock::new(match Settings::init() {
Ok(c) => c,
- Err(_) => Settings::default(),
+ Err(e) => {
+ warn!(
+ "Couldn't load settings file, using default settings.\n{}",
+ e
+ );
+ Settings::default()
+ }
});
}