response contains username but jwt is holding username also
This commit is contained in:
@@ -11,7 +11,7 @@ pub async fn login(
|
||||
) -> Result<Response<LoginResponse>, Status> {
|
||||
let user = sqlx::query!(
|
||||
r#"
|
||||
SELECT id, password_hash, role
|
||||
SELECT id, username, password_hash, role
|
||||
FROM users
|
||||
WHERE username = $1 OR email = $1
|
||||
"#,
|
||||
@@ -33,7 +33,7 @@ pub async fn login(
|
||||
return Err(Status::unauthenticated("Invalid credentials"));
|
||||
}
|
||||
|
||||
let token = jwt::generate_token(user.id, &user.role)
|
||||
let token = jwt::generate_token(user.id, &user.role, &user.username)
|
||||
.map_err(|e| Status::internal(e.to_string()))?;
|
||||
|
||||
Ok(Response::new(LoginResponse {
|
||||
@@ -42,5 +42,6 @@ pub async fn login(
|
||||
expires_in: 86400, // 24 hours
|
||||
user_id: user.id.to_string(),
|
||||
role: user.role,
|
||||
username: user.username,
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user