Some changes

pull/2/head
Jef Roosens 2021-11-23 09:54:47 +01:00
parent b423a57a9b
commit 4c07e18787
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
3 changed files with 19 additions and 6 deletions

View File

@ -5,10 +5,14 @@ use rand::{thread_rng, Rng};
use serde::{Deserialize, Serialize};
use sha2::Sha256;
use crate::{
errors::{RbError, RbResult},
RbJwtConf,
};
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct JwtConf {
key: String,
refresh_token_size: usize,
refresh_token_expire: i64,
}
use crate::errors::{RbError, RbResult};
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
@ -26,7 +30,7 @@ pub struct Claims {
}
pub fn generate_jwt_token(
jwt: &RbJwtConf,
jwt: &JwtConf,
id: uuid::Uuid,
username: String,
is_admin: bool,
@ -64,7 +68,7 @@ pub fn generate_jwt_token(
pub fn refresh_token(
conn: &PgConnection,
jwt: &RbJwtConf,
jwt: &JwtConf,
refresh_token: &str,
) -> RbResult<JWTResponse> {
let token_bytes =

8
src/config.rs 100644
View File

@ -0,0 +1,8 @@
use serde::{Serialize, Deserialize}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct RbJwtConf {
key: String,
refresh_token_size: usize,
refresh_token_expire: i64,
}

View File

@ -1,3 +1,4 @@
pub mod auth;
pub mod config;
pub mod errors;
pub mod guards;