mirror of https://gitee.com/xiaonuobase/snowy
修改验证码 为点选
parent
d1b1966f25
commit
a497693b82
|
@ -6,8 +6,8 @@ import { axios } from '@/utils/request'
|
||||||
// 获取验证图片 以及token
|
// 获取验证图片 以及token
|
||||||
export function reqGet(data) {
|
export function reqGet(data) {
|
||||||
return axios({
|
return axios({
|
||||||
url: '/captcha/code',
|
url: '/captcha/get',
|
||||||
method: 'get',
|
method: 'post',
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ export function reqGet(data) {
|
||||||
// 滑动或者点选验证
|
// 滑动或者点选验证
|
||||||
export function reqCheck(data) {
|
export function reqCheck(data) {
|
||||||
return axios({
|
return axios({
|
||||||
url: '/captcha/code/check',
|
url: '/captcha/check',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
|
|
|
@ -204,19 +204,19 @@ export default {
|
||||||
} = this
|
} = this
|
||||||
|
|
||||||
state.loginBtn = true
|
state.loginBtn = true
|
||||||
|
|
||||||
const validateFieldsKey = customActiveKey === 'tab1' ? ['account', 'password'] : ['mobile', 'captcha']
|
const validateFieldsKey = customActiveKey === 'tab1' ? ['account', 'password'] : ['mobile', 'captcha']
|
||||||
if (this.tenantOpen) {
|
if (this.tenantOpen) {
|
||||||
validateFieldsKey.push('tenantCode')
|
validateFieldsKey.push('tenantCode')
|
||||||
}
|
}
|
||||||
validateFields(validateFieldsKey, { force: true }, (err, values) => {
|
validateFields(validateFieldsKey, { force: true }, (err, values) => {
|
||||||
if (!err) {
|
|
||||||
this.loginParams = values
|
this.loginParams = values
|
||||||
// 是否开启验证码
|
// 是否开启验证码
|
||||||
if (this.captchaOpen) {
|
if (this.captchaOpen) {
|
||||||
this.$refs.verify.show()
|
this.$refs.verify.show()
|
||||||
|
state.loginBtn = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (!err) {
|
||||||
const loginParams = { ...values }
|
const loginParams = { ...values }
|
||||||
delete loginParams.account
|
delete loginParams.account
|
||||||
loginParams[!state.loginType ? 'email' : 'account'] = values.account
|
loginParams[!state.loginType ? 'email' : 'account'] = values.account
|
||||||
|
@ -242,6 +242,7 @@ export default {
|
||||||
*/
|
*/
|
||||||
verifySuccess(params) {
|
verifySuccess(params) {
|
||||||
this.loginParams.code = params.captchaVerification
|
this.loginParams.code = params.captchaVerification
|
||||||
|
console.log(this.loginParams)
|
||||||
this.Login(this.loginParams).then((res) => this.loginSuccess(res))
|
this.Login(this.loginParams).then((res) => this.loginSuccess(res))
|
||||||
.catch(err => this.requestFailed(err))
|
.catch(err => this.requestFailed(err))
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
|
|
@ -25,10 +25,8 @@ XiaoNuo采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注
|
||||||
package com.cn.xiaonuo.sys.modular.auth.controller;
|
package com.cn.xiaonuo.sys.modular.auth.controller;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Dict;
|
import cn.hutool.core.lang.Dict;
|
||||||
import com.anji.captcha.model.common.ResponseModel;
|
|
||||||
import com.anji.captcha.model.vo.CaptchaVO;
|
import com.anji.captcha.model.vo.CaptchaVO;
|
||||||
import com.anji.captcha.service.CaptchaService;
|
import com.anji.captcha.service.CaptchaService;
|
||||||
import com.cn.xiaonuo.core.consts.CommonConstant;
|
|
||||||
import com.cn.xiaonuo.core.context.constant.ConstantContextHolder;
|
import com.cn.xiaonuo.core.context.constant.ConstantContextHolder;
|
||||||
import com.cn.xiaonuo.core.context.login.LoginContextHolder;
|
import com.cn.xiaonuo.core.context.login.LoginContextHolder;
|
||||||
import com.cn.xiaonuo.core.exception.AuthException;
|
import com.cn.xiaonuo.core.exception.AuthException;
|
||||||
|
@ -130,31 +128,6 @@ public class SysLoginController {
|
||||||
return new SuccessResponseData(ConstantContextHolder.getCaptchaOpenFlag());
|
return new SuccessResponseData(ConstantContextHolder.getCaptchaOpenFlag());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description 获取验证码
|
|
||||||
* @Date 2021/1/21 15:25
|
|
||||||
* @author Jax
|
|
||||||
* @return ResponseModel
|
|
||||||
**/
|
|
||||||
@GetMapping("/captcha/code")
|
|
||||||
public ResponseModel getCode() {
|
|
||||||
CaptchaVO vo = new CaptchaVO();
|
|
||||||
vo.setCaptchaType(CommonConstant.IMAGE_CODE_TYPE);
|
|
||||||
return captchaService.get(vo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description 校验前端验证码
|
|
||||||
* @Date 2021/1/21 15:26
|
|
||||||
* @author Jax
|
|
||||||
* @param captcha
|
|
||||||
* @return ResponseModel
|
|
||||||
**/
|
|
||||||
@PostMapping("/captcha/code/check")
|
|
||||||
public ResponseModel check(@RequestBody CaptchaVO captcha) {
|
|
||||||
return captchaService.check(captcha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description 校验验证码
|
* @Description 校验验证码
|
||||||
* @Date 2021/1/21 15:27
|
* @Date 2021/1/21 15:27
|
||||||
|
|
|
@ -13,36 +13,36 @@ import java.util.concurrent.TimeUnit;
|
||||||
* @Author Jax
|
* @Author Jax
|
||||||
* @Date 2021/1/21 16:27
|
* @Date 2021/1/21 16:27
|
||||||
**/
|
**/
|
||||||
//public class CaptchaCacheServiceProvider implements CaptchaCacheService {
|
public class CaptchaCacheServiceProvider implements CaptchaCacheService {
|
||||||
//
|
|
||||||
// private static final String REDIS = "redis";
|
private static final String REDIS = "redis";
|
||||||
//
|
|
||||||
// @Autowired
|
@Autowired
|
||||||
// private StringRedisTemplate stringRedisTemplate;
|
private StringRedisTemplate stringRedisTemplate;
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public void set(String key, String value, long expiresInSeconds) {
|
public void set(String key, String value, long expiresInSeconds) {
|
||||||
// stringRedisTemplate.opsForValue().set(key, value, expiresInSeconds, TimeUnit.SECONDS);
|
stringRedisTemplate.opsForValue().set(key, value, expiresInSeconds, TimeUnit.SECONDS);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public boolean exists(String key) {
|
public boolean exists(String key) {
|
||||||
// return stringRedisTemplate.hasKey(key);
|
return stringRedisTemplate.hasKey(key);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public void delete(String key) {
|
public void delete(String key) {
|
||||||
// stringRedisTemplate.delete(key);
|
stringRedisTemplate.delete(key);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public String get(String key) {
|
public String get(String key) {
|
||||||
// return stringRedisTemplate.opsForValue().get(key);
|
return stringRedisTemplate.opsForValue().get(key);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public String type() {
|
public String type() {
|
||||||
// return REDIS;
|
return REDIS;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//}
|
}
|
||||||
|
|
|
@ -59,5 +59,6 @@ jodconverter:
|
||||||
#验证码相关配置
|
#验证码相关配置
|
||||||
aj:
|
aj:
|
||||||
captcha:
|
captcha:
|
||||||
type: clickword #验证码类型 为点选
|
cache-type: local #分布式部署需要 自己实现CaptchaCacheService 使用redis需要配置redis相关配置
|
||||||
|
type: clickword #验证码类型 为点选 blockPuzzle 为滑块验证码
|
||||||
font-type: 宋体
|
font-type: 宋体
|
||||||
|
|
Loading…
Reference in New Issue