疯狂的狮子li
2021-07-13 fd5414f82e6305eaf35297f63f9e7c95615f99e3
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
已修改7个文件
已重命名1个文件
118 ■■■■■ 文件已修改
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/components/Editor/index.vue 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/components/ImageUpload/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/login.vue 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sql/ry_20210713.sql 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
@@ -14,6 +14,7 @@
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;
@@ -26,7 +27,7 @@
/**
 * éªŒè¯ç æ“ä½œå¤„理
 *
 * @author Lion Li
 * @author ruoyi
 */
@RestController
public class CaptchaController {
@@ -47,15 +48,18 @@
    @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);
        }
        // ä¿å­˜éªŒè¯ç ä¿¡æ¯
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
@@ -12,6 +12,7 @@
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;
@@ -47,6 +48,9 @@
    private ISysUserService userService;
    @Autowired
    private ISysConfigService configService;
    @Autowired
    private AsyncService asyncService;
    /**
@@ -60,20 +64,12 @@
     */
    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
@@ -103,6 +99,29 @@
    }
    /**
     * æ ¡éªŒéªŒè¯ç 
     *
     * @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)
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java
@@ -33,6 +33,13 @@
    public String selectConfigByKey(String configKey);
    /**
     * èŽ·å–éªŒè¯ç å¼€å…³
     *
     * @return true开启,false关闭
     */
    public boolean selectCaptchaOnOff();
    /**
     * æŸ¥è¯¢å‚数配置列表
     *
     * @param config å‚数配置信息
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java
@@ -94,6 +94,19 @@
    }
    /**
     * èŽ·å–éªŒè¯ç å¼€å…³
     *
     * @return true开启,false关闭
     */
    public boolean selectCaptchaOnOff() {
        String captchaOnOff = selectConfigByKey("sys.account.captchaOnOff");
        if (StrUtil.isEmpty(captchaOnOff)) {
            return true;
        }
        return Convert.toBool(captchaOnOff);
    }
    /**
     * æŸ¥è¯¢å‚数配置列表
     *
     * @param config å‚数配置信息
ruoyi-ui/src/components/Editor/index.vue
@@ -130,14 +130,14 @@
            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) => {
ruoyi-ui/src/components/ImageUpload/index.vue
@@ -116,7 +116,7 @@
  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));
    },
ruoyi-ui/src/views/login.vue
@@ -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" v-if="captchaEnabled">
      <el-form-item prop="code" v-if="captchaOnOff">
        <el-input
          v-model="loginForm.code"
          auto-complete="off"
@@ -81,8 +81,8 @@
        code: [{ required: true, trigger: "change", message: "验证码不能为空" }]
      },
      loading: false,
      redirect: undefined,
      captchaEnabled:false
      captchaOnOff: true,
      redirect: undefined
    };
  },
  watch: {
@@ -100,8 +100,8 @@
  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;
        }
@@ -134,7 +134,9 @@
            this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
          }).catch(() => {
            this.loading = false;
            this.getCode();
            if (this.captchaOnOff) {
              this.getCode();
            }
          });
        }
      });
sql/ry_20210713.sql
ÎļþÃû´Ó sql/ry_20210210.sql ÐÞ¸Ä
@@ -537,9 +537,10 @@
  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关闭)');
-- ----------------------------