Some changes
parent
b423a57a9b
commit
4c07e18787
|
@ -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 =
|
||||
|
|
|
@ -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,
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
pub mod auth;
|
||||
pub mod config;
|
||||
pub mod errors;
|
||||
pub mod guards;
|
||||
|
|
Loading…
Reference in New Issue