mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 23:43:18 +00:00
A few suggestion fixes.
This commit is contained in:
parent
05b485b678
commit
493598c1ba
|
@ -118,7 +118,7 @@ pub(crate) fn check_validator_time(
|
|||
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 {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::settings::structs::Settings;
|
||||
use chrono::Utc;
|
||||
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -30,7 +31,7 @@ impl Claims {
|
|||
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(),
|
||||
|
|
|
@ -13,6 +13,7 @@ use crate::{
|
|||
};
|
||||
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};
|
||||
|
||||
|
@ -24,7 +25,13 @@ static CONFIG_FILE: &str = "config/config.hjson";
|
|||
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()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue