auth: Introduce User struct
The `UserClaims` structure is an implementation detail of how the JWT encoding process works. We do not need to expose all of the details of the JWT, such as issuer, audience, expiration, etc. to rest of the application. Route handlers should only be concerned with the information about the user, rather than the metadata about how the user was authenticated.
This commit is contained in:
@@ -78,7 +78,9 @@ async fn test_login() {
|
||||
assert_eq!(location, "/");
|
||||
let cookie = res.cookies().get("auth.token").unwrap();
|
||||
debug!("Cookie: {:?}", cookie);
|
||||
let claims = ctx.decode_jwt(cookie.value()).unwrap();
|
||||
debug!("Claims: {:?}", claims);
|
||||
assert!(!claims.sub.is_empty());
|
||||
|
||||
// Check to ensure the cookie contains a valid token
|
||||
let user = ctx.decode_jwt(cookie.value()).unwrap();
|
||||
debug!("User: {:?}", user);
|
||||
assert!(!user.id().is_empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user