Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
Conflicts:
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java
ruoyi-ui/src/components/ImageUpload/index.vue
ruoyi-ui/src/views/login.vue
sql/ry_20210713.sql
| | |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.framework.captcha.UnsignedMathGenerator; |
| | | import com.ruoyi.framework.config.properties.CaptchaProperties; |
| | | 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.RestController; |
| | |
| | | /** |
| | | * éªè¯ç æä½å¤ç |
| | | * |
| | | * @author Lion Li |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | public class CaptchaController { |
| | |
| | | @Autowired |
| | | private CaptchaProperties captchaProperties; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | /** |
| | | * çæéªè¯ç |
| | | */ |
| | | @GetMapping("/captchaImage") |
| | | public AjaxResult getCode() { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | Boolean enabled = captchaProperties.getEnabled(); |
| | | ajax.put("enabled", enabled); |
| | | if (!enabled) { |
| | | boolean captchaOnOff = configService.selectCaptchaOnOff(); |
| | | ajax.put("captchaOnOff", captchaOnOff); |
| | | if (!captchaOnOff) { |
| | | return AjaxResult.success(ajax); |
| | | } |
| | | // ä¿åéªè¯ç ä¿¡æ¯ |
| | |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.framework.config.properties.CaptchaProperties; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | @Autowired |
| | | private AsyncService asyncService; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public String login(String username, String password, String code, String uuid) |
| | | { |
| | | HttpServletRequest request = ServletUtils.getRequest(); |
| | | if(captchaProperties.getEnabled()) { |
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; |
| | | String captcha = redisCache.getCacheObject(verifyKey); |
| | | redisCache.deleteObject(verifyKey); |
| | | if (captcha == null) { |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"), request); |
| | | throw new CaptchaExpireException(); |
| | | } |
| | | if (!code.equalsIgnoreCase(captcha)) { |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"), request); |
| | | throw new CaptchaException(); |
| | | } |
| | | } |
| | | boolean captchaOnOff = configService.selectCaptchaOnOff(); |
| | | // éªè¯ç å¼å
³ |
| | | if (captchaOnOff) |
| | | { |
| | | validateCapcha(username, code, uuid); |
| | | } |
| | | // ç¨æ·éªè¯ |
| | | Authentication authentication = null; |
| | | try |
| | |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªéªè¯ç |
| | | * |
| | | * @param username ç¨æ·å |
| | | * @param code éªè¯ç |
| | | * @param uuid å¯ä¸æ è¯ |
| | | * @return ç»æ |
| | | */ |
| | | public void validateCapcha(String username, String code, String uuid) { |
| | | HttpServletRequest request = ServletUtils.getRequest(); |
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; |
| | | String captcha = redisCache.getCacheObject(verifyKey); |
| | | redisCache.deleteObject(verifyKey); |
| | | if (captcha == null) { |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"), request); |
| | | throw new CaptchaExpireException(); |
| | | } |
| | | if (!code.equalsIgnoreCase(captcha)) { |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"), request); |
| | | throw new CaptchaException(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è®°å½ç»å½ä¿¡æ¯ |
| | | */ |
| | | public void recordLoginInfo(SysUser user) |
| | |
| | | public String selectConfigByKey(String configKey); |
| | | |
| | | /** |
| | | * è·åéªè¯ç å¼å
³ |
| | | * |
| | | * @return trueå¼å¯ï¼falseå
³é |
| | | */ |
| | | public boolean selectCaptchaOnOff(); |
| | | |
| | | /** |
| | | * æ¥è¯¢åæ°é
ç½®å表 |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | |
| | | } |
| | | |
| | | /** |
| | | * è·åéªè¯ç å¼å
³ |
| | | * |
| | | * @return trueå¼å¯ï¼falseå
³é |
| | | */ |
| | | public boolean selectCaptchaOnOff() { |
| | | String captchaOnOff = selectConfigByKey("sys.account.captchaOnOff"); |
| | | if (StrUtil.isEmpty(captchaOnOff)) { |
| | | return true; |
| | | } |
| | | return Convert.toBool(captchaOnOff); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢åæ°é
ç½®å表 |
| | | * |
| | | * @param config åæ°é
ç½®ä¿¡æ¯ |
| | |
| | | this.quill.format("image", false); |
| | | } |
| | | }); |
| | | toolbar.addHandler("video", (value) => { |
| | | this.uploadType = "video"; |
| | | if (value) { |
| | | this.$refs.upload.$children[0].$refs.input.click(); |
| | | } else { |
| | | this.quill.format("video", false); |
| | | } |
| | | }); |
| | | // toolbar.addHandler("video", (value) => { |
| | | // this.uploadType = "video"; |
| | | // if (value) { |
| | | // this.$refs.upload.$children[0].$refs.input.click(); |
| | | // } else { |
| | | // this.quill.format("video", false); |
| | | // } |
| | | // }); |
| | | } |
| | | this.Quill.pasteHTML(this.currentValue); |
| | | this.Quill.on("text-change", (delta, oldDelta, source) => { |
| | |
| | | methods: { |
| | | // å é¤å¾ç |
| | | handleRemove(file, fileList) { |
| | | const findex = this.fileList.indexOf(file.name); |
| | | const findex = this.fileList.map(f => f.name).indexOf(file.name); |
| | | this.fileList.splice(findex, 1); |
| | | this.$emit("input", this.listToString(this.fileList)); |
| | | }, |
| | |
| | | <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="code" v-if="captchaEnabled"> |
| | | <el-form-item prop="code" v-if="captchaOnOff"> |
| | | <el-input |
| | | v-model="loginForm.code" |
| | | auto-complete="off" |
| | |
| | | code: [{ required: true, trigger: "change", message: "éªè¯ç ä¸è½ä¸ºç©º" }] |
| | | }, |
| | | loading: false, |
| | | redirect: undefined, |
| | | captchaEnabled:false |
| | | captchaOnOff: true, |
| | | redirect: undefined |
| | | }; |
| | | }, |
| | | watch: { |
| | |
| | | methods: { |
| | | getCode() { |
| | | getCodeImg().then(res => { |
| | | this.captchaEnabled = res.data.enabled; |
| | | if(res.data.enabled){ |
| | | this.captchaOnOff = res.data.captchaOnOff === undefined ? true : res.data.captchaOnOff; |
| | | if (this.captchaOnOff) { |
| | | this.codeUrl = "data:image/gif;base64," + res.data.img; |
| | | this.loginForm.uuid = res.data.uuid; |
| | | } |
| | |
| | | this.$router.push({ path: this.redirect || "/" }).catch(()=>{}); |
| | | }).catch(() => { |
| | | this.loading = false; |
| | | this.getCode(); |
| | | if (this.captchaOnOff) { |
| | | this.getCode(); |
| | | } |
| | | }); |
| | | } |
| | | }); |
ÎļþÃû´Ó sql/ry_20210210.sql ÐÞ¸Ä |
| | |
| | | primary key (config_id) |
| | | ) engine=innodb auto_increment=100 comment = 'åæ°é
置表'; |
| | | |
| | | insert into sys_config values(1, 'ä¸»æ¡æ¶é¡µ-é»è®¤ç®è¤æ ·å¼åç§°', 'sys.index.skinName', 'skin-blue', 'Y', 'admin', sysdate(), '', null, 'èè² skin-blueãç»¿è² skin-greenãç´«è² skin-purpleãçº¢è² skin-redãé»è² skin-yellow' ); |
| | | insert into sys_config values(2, 'ç¨æ·ç®¡ç-è´¦å·åå§å¯ç ', 'sys.user.initPassword', '123456', 'Y', 'admin', sysdate(), '', null, 'åå§åå¯ç 123456' ); |
| | | insert into sys_config values(3, 'ä¸»æ¡æ¶é¡µ-ä¾§è¾¹æ 主é¢', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', sysdate(), '', null, 'æ·±è²ä¸»é¢theme-darkï¼æµ
è²ä¸»é¢theme-light' ); |
| | | insert into sys_config values(1, 'ä¸»æ¡æ¶é¡µ-é»è®¤ç®è¤æ ·å¼åç§°', 'sys.index.skinName', 'skin-blue', 'Y', 'admin', sysdate(), '', null, 'èè² skin-blueãç»¿è² skin-greenãç´«è² skin-purpleãçº¢è² skin-redãé»è² skin-yellow' ); |
| | | insert into sys_config values(2, 'ç¨æ·ç®¡ç-è´¦å·åå§å¯ç ', 'sys.user.initPassword', '123456', 'Y', 'admin', sysdate(), '', null, 'åå§åå¯ç 123456' ); |
| | | insert into sys_config values(3, 'ä¸»æ¡æ¶é¡µ-ä¾§è¾¹æ 主é¢', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', sysdate(), '', null, 'æ·±è²ä¸»é¢theme-darkï¼æµ
è²ä¸»é¢theme-light' ); |
| | | insert into sys_config values(4, 'è´¦å·èªå©-éªè¯ç å¼å
³', 'sys.account.captchaOnOff', 'true', 'Y', 'admin', sysdate(), '', null, 'æ¯å¦å¼å¯ç»å½éªè¯ç åè½ï¼trueå¼å¯ï¼falseå
³éï¼'); |
| | | |
| | | |
| | | -- ---------------------------- |