新增ip地区限制
This commit is contained in:
@@ -14,6 +14,7 @@ import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Account;
|
||||
import com.accompany.core.model.AccountH5LoginRecord;
|
||||
import com.accompany.core.mybatismapper.AccountH5LoginRecordMapper;
|
||||
import com.accompany.core.mybatismapper.AccountLoginRecordMapperExpand;
|
||||
import com.accompany.core.service.account.AccountService;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.util.JwtUtils;
|
||||
@@ -48,6 +49,8 @@ public class AccountH5LoginService {
|
||||
@Autowired
|
||||
private AccountH5LoginRecordMapper accountH5LoginRecordMapper;
|
||||
@Autowired
|
||||
private AccountLoginRecordMapperExpand accountLoginRecordMapperExpand;
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
@@ -167,6 +170,10 @@ public class AccountH5LoginService {
|
||||
jedisService.hset(RedisKey.h5loginjwtoken.getKey(), uid.toString(), jwtToken);
|
||||
}
|
||||
|
||||
private void deleteH5LoginJwtToken(Long uid) {
|
||||
jedisService.hdel(RedisKey.h5loginjwtoken.getKey(), uid.toString());
|
||||
}
|
||||
|
||||
public void register(String mobile, String code, String inviteCode, Long inviteUid, DeviceInfo deviceInfo, String ipAddress, String phoneAreaCode) {
|
||||
// 校验验证码
|
||||
if (!smsService.verifySmsCode(mobile, code)) {
|
||||
@@ -214,7 +221,16 @@ public class AccountH5LoginService {
|
||||
Map<String, H5TokenGranter> tokenGranterMap = SpringContextHolder.getApplicationContext().getBeansOfType(H5TokenGranter.class);
|
||||
for (H5TokenGranter tokenGranter : tokenGranterMap.values()) {
|
||||
if (tokenGranter.getGrantType().equals(grantType)) {
|
||||
return tokenGranter.getAuthentication(request);
|
||||
H5AccessToken token = tokenGranter.getAuthentication(request);
|
||||
if (token != null) {
|
||||
Long uid = token.getUid();
|
||||
Integer isExists = accountLoginRecordMapperExpand.isExists(uid);
|
||||
if (isExists > 0) {
|
||||
deleteH5LoginJwtToken(uid);
|
||||
throw new ApiException(403, "暂未在你所在的地区开放");
|
||||
}
|
||||
}
|
||||
return token;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user