master
luoyang 6 years ago
parent f1bcd03b81
commit 99893846b1

@ -7,6 +7,8 @@ import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.device.DeviceSupport;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.code.kaptcha.Producer;
@ -42,6 +44,11 @@ public class RetailValidationController {
return deviceSupport.register(devType, registeration);
}
@RequestMapping(value = "/devices/{devType}/manage/register", method = RequestMethod.POST)
public JSONObject manageRegister(@RequestBody String registeration, @PathVariable String devType) {
return deviceSupport.register(devType, registeration);
}
@RequestMapping(value = "/sign_in_check", method = RequestMethod.POST)
public JSONObject signIn(@RequestBody @Valid RetailLoginInfo loginInfo, Errors errors) {
HttpUtils.handleValidErrors(errors);
@ -64,6 +71,31 @@ public class RetailValidationController {
return client;
}
@RequestMapping(value = "/manage/sign_in_check", method = RequestMethod.POST)
public JSONObject manageSignIn(@RequestBody @Valid RetailLoginInfo loginInfo, Errors errors) {
HttpUtils.handleValidErrors(errors);
String codeValue = signInStatusManager.getVerifyCode(loginInfo.getCaptchaKey());
if (codeValue == null) {
throw new BadRequestException("Verification code has expired");
}
if (!codeValue.equals(loginInfo.getVerifyCode())) {
throw new BadRequestException("Verification code is not correct");
} else {
signInStatusManager.deleteVerifyCodeKey(loginInfo.getCaptchaKey());
}
String signKey = signInStatusManager.managerSignIn(loginInfo.toLoginInfo());
JSONObject manager = signInStatusManager.getCurrentManager(signKey);
manager = JSON.parseObject(manager.toJSONString());
if (!ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) {
throw new BadRequestException(LocaleSupport.localeMessage("error.login.password"));
}
// if (loginInfo.getDevId() != null) {
// deviceSupport.validDeviceWithClient(manager, loginInfo.getDevId());
// }
manager.put("sign_key", signKey);
return manager;
}
@RequestMapping(value = "/wechat_app_signin", method = RequestMethod.POST)
public JSONObject partnerWechatAppSignIn(@RequestBody JSONObject data) {
JSONObject res = signInStatusManager.partnerWechatAppSignIn(data.getString("code"));

Loading…
Cancel
Save