|
@@ -108,6 +108,46 @@ public class SysLoginService {
|
|
|
return tokenService.createToken(loginUser);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * OPPO 青少年模式验证
|
|
|
+ *
|
|
|
+ * @param username 用户名
|
|
|
+ * @param password 密码
|
|
|
+ * @param code 验证码
|
|
|
+ * @param uuid 唯一标识
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ public Boolean verifyLogin(String username, String password, String code, String uuid, boolean isCommunity) {
|
|
|
+ // 验证码校验
|
|
|
+ validateCaptcha(username, code, uuid);
|
|
|
+ // 登录前置校验
|
|
|
+ loginPreCheck(username, password);
|
|
|
+ // 用户验证
|
|
|
+ Authentication authentication = null;
|
|
|
+ Boolean isLogin = false;
|
|
|
+
|
|
|
+ try {
|
|
|
+ UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
|
|
|
+ AuthenticationContextHolder.setContext(authenticationToken);
|
|
|
+ // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
|
|
+ authentication = authenticationManager.authenticate(authenticationToken);
|
|
|
+ } catch (Exception e) {
|
|
|
+ if (e instanceof BadCredentialsException) {
|
|
|
+ AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
|
|
|
+ return isLogin;
|
|
|
+ } else {
|
|
|
+ AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
|
|
|
+ return isLogin;
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ AuthenticationContextHolder.clearContext();
|
|
|
+ }
|
|
|
+ isLogin = true;
|
|
|
+ // 生成token
|
|
|
+ return isLogin;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 微信登录
|
|
|
*
|