Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ezesundayeze committed Nov 29, 2023
1 parent 4dc1519 commit d1919c6
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,29 @@ refresh token handler which should look like this:
use axum_jwt_ware::{CurrentUser, Claims, UserData, Algorithm, refresh_token};

let app = Router::new()
.route("/refresh", post(move | body: Json<axum_jwt_ware::RequestBody>| {
.route("/refresh", get(move | body: Json<axum_jwt_ware::RequestBody>| {

let header = &Header::default();
let key = EncodingKey::from_secret(jwt_secret.as_ref());
let expiry_timestamp = Utc::now() + Duration::hours(48);

let claims = Claims {
sub: user.id,
username: user.username.clone(),
exp: expiry_timestamp,
};
let claims = Claims {
sub: user.id,
username: user.username.clone(),
exp: expiry_timestamp,
};

let encoding_info = EncodingContext {
header: &Header::default(),
key: EncodingKey::from_secret(jwt_secret.as_ref()).
validation: Validation::default(),
}

token: &str,
encoding_info: EncodingContext,
decoding_info: DecodingContext,
claims: Claims,
let decoding_info = DecodingContext{
header: &Header::default(),
key: DecodingKey::from_secret(jwt_secret.as_ref()).
validation: Validation::default(),
}

refresh_token(token, claims, ) // login returns {username, token}
refresh_token(token, encoding_info, decoding_info, claims) // login returns {username, token}
}));
```

Expand Down

0 comments on commit d1919c6

Please sign in to comment.