supported app multiple signin requirement according to public-server change

This commit is contained in:
strawmanbobi
2020-09-22 21:53:51 +08:00
parent 3489a88f64
commit fb6a0a0cb8
3 changed files with 9 additions and 8 deletions

View File

@@ -14,7 +14,7 @@ public interface IUserAppRepository {
void add(Integer id, String token);
void delete(Integer id);
void delete(String token);
String find(Integer id);
Integer find(String token);
}

View File

@@ -38,15 +38,15 @@ public class UserAppRepositoryImpl implements IUserAppRepository {
}
public void add(Integer id, String token) {
hashOperations.put(KEY, id, token);
hashOperations.put(KEY, token, id);
}
public void delete(final Integer id) {
hashOperations.delete(KEY, id);
public void delete(final String token) {
hashOperations.delete(KEY, token);
}
public String find(final Integer id) {
return (String) hashOperations.get(KEY, id);
public Integer find(final String token) {
return (Integer)hashOperations.get(KEY, token);
}
}

View File

@@ -95,7 +95,8 @@ public abstract class AbstractBaseService implements TokenValidation {
private Status validateUserToken(Integer userId, String token) {
Status status = new Status();
if (userAppRepository.find(userId).equals(token)) {
Integer cachedId = userAppRepository.find(token);
if (null != cachedId && cachedId.equals(userId)) {
status.setCode(Constants.ERROR_CODE_SUCCESS);
} else {
status.setCode(Constants.ERROR_CODE_AUTH_FAILURE);