添加验证码开关
This commit is contained in:
parent
67feb9947e
commit
16d9989e2f
|
|
@ -4,6 +4,7 @@ import java.nio.CharBuffer;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
|
|
@ -36,6 +37,9 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
|||
|
||||
private static final String UUID = "uuid";
|
||||
|
||||
@Value("${ruoyi.captchaEnabled}")
|
||||
private boolean captchaEnabled;
|
||||
|
||||
@Override
|
||||
public GatewayFilter apply(Object config)
|
||||
{
|
||||
|
|
@ -48,19 +52,18 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
|||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (captchaEnabled) {
|
||||
try {
|
||||
String rspStr = resolveBodyFromRequest(request);
|
||||
JSONObject obj = JSONObject.parseObject(rspStr);
|
||||
validateCodeService.checkCapcha(obj.getString(CODE), obj.getString(UUID));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
response.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
|
||||
return exchange.getResponse().writeWith(
|
||||
Mono.just(response.bufferFactory().wrap(JSON.toJSONBytes(AjaxResult.error(e.getMessage())))));
|
||||
}
|
||||
}
|
||||
return chain.filter(exchange);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,5 +37,9 @@ module.exports = {
|
|||
* The default is only used in the production env
|
||||
* If you want to also use it in dev, you can pass ['production', 'development']
|
||||
*/
|
||||
errorLog: 'production'
|
||||
errorLog: 'production',
|
||||
/**
|
||||
* 是否显示验证码
|
||||
*/
|
||||
captchaEnabled:false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="code">
|
||||
<el-form-item prop="code" v-if="this.captchaEnabled">
|
||||
<el-input
|
||||
v-model="loginForm.code"
|
||||
auto-complete="off"
|
||||
|
|
@ -81,7 +81,8 @@ export default {
|
|||
code: [{ required: true, trigger: "change", message: "验证码不能为空" }]
|
||||
},
|
||||
loading: false,
|
||||
redirect: undefined
|
||||
redirect: undefined,
|
||||
captchaEnabled: this.$store.state.settings.captchaEnabled
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
|
|
@ -93,7 +94,9 @@ export default {
|
|||
}
|
||||
},
|
||||
created() {
|
||||
if (this.captchaEnabled){
|
||||
this.getCode();
|
||||
}
|
||||
this.getCookie();
|
||||
},
|
||||
methods: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue