Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not include "email": null in JWT (if there is no email) #964

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions backend/src/auth/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ impl JwtContext {
+ chrono::Duration::from_std(self.config.expiration_time)
.expect("failed to convert from std Duration to chrono::Duration");

let payload = json!({
let mut payload = json!({
"name": user.display_name,
"username": user.username,
"email": user.email,
"exp": exp.timestamp(),
});
if let Some(email) = &user.email {
payload.as_object_mut().unwrap().insert("email".into(), email.clone().into());
}


self.encode(&payload)
}
Expand Down