Skip to content

Commit

Permalink
Support 3PID in memory identity store profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Dor committed Mar 30, 2018
1 parent 7f9c7aa commit ac6f549
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/java/io/kamax/mxisd/auth/AuthManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.kamax.matrix.MatrixID;
import io.kamax.matrix.ThreePid;
import io.kamax.matrix._MatrixID;
import io.kamax.matrix._ThreePid;
import io.kamax.mxisd.UserIdType;
import io.kamax.mxisd.auth.provider.AuthenticatorProvider;
import io.kamax.mxisd.auth.provider.BackendAuthResult;
Expand Down Expand Up @@ -72,7 +73,7 @@ public UserAuthResult authenticate(String id, String password) {
}

UserAuthResult authResult = new UserAuthResult().success(result.getProfile().getDisplayName());
for (ThreePid pid : result.getProfile().getThreePids()) {
for (_ThreePid pid : result.getProfile().getThreePids()) {
authResult.withThreePid(pid.getMedium(), pid.getAddress());
}
log.info("{} was authenticated by {}, publishing 3PID mappings, if any", id, provider.getClass().getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

package io.kamax.mxisd.auth.provider;

import io.kamax.matrix.ThreePid;
import io.kamax.matrix._ThreePid;
import io.kamax.mxisd.UserID;
import io.kamax.mxisd.UserIdType;

Expand All @@ -32,13 +32,13 @@ public class BackendAuthResult {
public static class BackendAuthProfile {

private String displayName;
private Set<ThreePid> threePids = new HashSet<>();
private Set<_ThreePid> threePids = new HashSet<>();

public String getDisplayName() {
return displayName;
}

public Set<ThreePid> getThreePids() {
public Set<_ThreePid> getThreePids() {
return threePids;
}
}
Expand Down Expand Up @@ -85,7 +85,7 @@ public BackendAuthProfile getProfile() {
return profile;
}

public BackendAuthResult withThreePid(ThreePid threePid) {
public BackendAuthResult withThreePid(_ThreePid threePid) {
this.profile.threePids.add(threePid);

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ public BackendAuthResult authenticate(_MatrixID mxid, String password) {
if (!StringUtils.equals(id.getUsername(), mxid.getLocalPart())) {
return BackendAuthResult.failure();
} else {
return BackendAuthResult.success(mxid.getId(), UserIdType.MatrixID, "");
BackendAuthResult result = new BackendAuthResult();
id.getThreepids().forEach(result::withThreePid);
result.succeed(mxid.getId(), UserIdType.MatrixID.getId(), "");
return result;
}
}).orElseGet(BackendAuthResult::failure);
}
Expand Down

0 comments on commit ac6f549

Please sign in to comment.