diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java index f1552e033..2d4b6b823 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java @@ -1,15 +1,16 @@ package com.ruoyi.web.controller.system; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.model.RegisterBody; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.web.service.SysRegisterService; import com.ruoyi.system.service.ISysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; /** * 注册验证 @@ -35,4 +36,12 @@ public class SysRegisterController extends BaseController String msg = registerService.register(user); return StringUtils.isEmpty(msg) ? success() : error(msg); } + @GetMapping("/registerSwitch") + public AjaxResult registerSwitch() + { + AjaxResult ajax = AjaxResult.success(); + String registerUser = configService.selectConfigByKey("sys.account.registerUser"); + ajax.put("registerUser", "true".equals(registerUser) ? Boolean.TRUE : Boolean.FALSE); + return ajax; + } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 58dd02ad0..c6fd6f818 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter // 过滤请求 .authorizeRequests() // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - .antMatchers("/login", "/register", "/captchaImage").anonymous() + .antMatchers("/login", "/register", "/captchaImage","/registerSwitch").anonymous() .antMatchers( HttpMethod.GET, "/", diff --git a/ruoyi-ui/src/api/login.js b/ruoyi-ui/src/api/login.js index 26742e79c..3a76e8480 100644 --- a/ruoyi-ui/src/api/login.js +++ b/ruoyi-ui/src/api/login.js @@ -56,4 +56,15 @@ export function getCodeImg() { method: 'get', timeout: 20000 }) +} + +// 获取是否自助注册 +export function getRegisterSwitch() { + return request({ + url: '/registerSwitch', + headers: { + isToken: false + }, + method: 'get', + }) } \ No newline at end of file diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue index 6e240dd24..4f6cbfc66 100644 --- a/ruoyi-ui/src/views/login.vue +++ b/ruoyi-ui/src/views/login.vue @@ -62,7 +62,7 @@ </template> <script> -import { getCodeImg } from "@/api/login"; +import { getCodeImg, getRegisterSwitch } from "@/api/login"; import Cookies from "js-cookie"; import { encrypt, decrypt } from '@/utils/jsencrypt' @@ -105,6 +105,7 @@ export default { }, created() { this.getCode(); + this.getRegisterUser(); this.getCookie(); }, methods: { @@ -117,6 +118,11 @@ export default { } }); }, + getRegisterUser() { + getRegisterSwitch().then(res =>{ + this.register = res.registerUser === undefined ? false : res.registerUser; + }) + }, getCookie() { const username = Cookies.get("username"); const password = Cookies.get("password");