Skip to content

Commit

Permalink
Update HTTP login model
Browse files Browse the repository at this point in the history
  • Loading branch information
mmodzelewski committed Nov 12, 2023
1 parent 7a591ae commit a2117e5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/rs/iggy/http/UsersHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void changePassword(UserId userId, String currentPassword, String newPass
public IdentityInfo login(String username, String password) {
var request = httpClient.preparePostRequest(USERS + "/login", new Login(username, password));
var response = httpClient.execute(request, IdentityInfo.class);
httpClient.setToken(response.token());
httpClient.setToken(response.tokens().map(IdentityTokens::accessToken).map(TokenInfo::token));
return response;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rs/iggy/user/IdentityInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

import java.util.Optional;

public record IdentityInfo(Long userId, Optional<String> token) {
public record IdentityInfo(Long userId, Optional<IdentityTokens> tokens) {
}
4 changes: 4 additions & 0 deletions src/main/java/rs/iggy/user/IdentityTokens.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package rs.iggy.user;

public record IdentityTokens(TokenInfo accessToken, TokenInfo refreshToken) {
}
6 changes: 6 additions & 0 deletions src/main/java/rs/iggy/user/TokenInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package rs.iggy.user;

import java.math.BigInteger;

public record TokenInfo(String token, BigInteger expiry) {
}

0 comments on commit a2117e5

Please sign in to comment.