mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-24 20:42:15 +00:00
feat: application_id in jwt
This commit is contained in:
parent
e3c5052ffc
commit
04bc69501f
2 changed files with 4 additions and 1 deletions
|
|
@ -7,16 +7,18 @@ pub struct CandidateToken {
|
|||
pub iat: i64,
|
||||
// expiration
|
||||
pub exp: i64,
|
||||
pub application_id: i32,
|
||||
pub name: String,
|
||||
pub surname: String,
|
||||
}
|
||||
|
||||
impl CandidateToken {
|
||||
pub fn generate(name: String, surname: String) -> Self {
|
||||
pub fn generate(application_id: i32, name: String, surname: String) -> Self {
|
||||
let now = Utc::now().timestamp();
|
||||
CandidateToken {
|
||||
iat: now,
|
||||
exp: now + 60 * 60, // 1 hour for now
|
||||
application_id,
|
||||
name,
|
||||
surname,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ pub fn generate_candidate_token(candidate: candidate::Model) -> String {
|
|||
let payload = CandidateToken {
|
||||
iat: now,
|
||||
exp: now + ONE_WEEK,
|
||||
application_id: candidate.application,
|
||||
name: candidate.name.unwrap_or_else(|| "".into()),
|
||||
surname: candidate.surname.unwrap_or_else(|| "".into()),
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue