feat: application_id in jwt

This commit is contained in:
Sebastian Pravda 2022-10-26 10:55:53 +02:00
parent e3c5052ffc
commit 04bc69501f
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57
2 changed files with 4 additions and 1 deletions

View file

@ -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,
}

View file

@ -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()),
};