Просмотр исходного кода

用户管理功能前端添加重放和修改提示框的bug

xusl 1 год назад
Родитель
Сommit
a375205eee

+ 15 - 0
backend/src/main/java/com/jiayue/ssi/annotation/PreventReplay.java

@@ -0,0 +1,15 @@
+package com.jiayue.ssi.annotation;
+
+import java.lang.annotation.*;
+
+/**
+* 防重放
+*
+* @author xsl
+* @since 2023/05/24
+*/
+@Documented
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface PreventReplay {
+}

+ 62 - 0
backend/src/main/java/com/jiayue/ssi/aspectj/PreventReplayAspect.java

@@ -0,0 +1,62 @@
+package com.jiayue.ssi.aspectj;
+
+import com.jiayue.ssi.util.*;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+* 防重放
+*
+* @author xsl
+* @since 2023/05/24
+*/
+@Aspect
+@Component
+@Slf4j
+@Order(2)
+public class PreventReplayAspect {
+    /**
+     * 定义切点
+     */
+    @Pointcut("@annotation(com.jiayue.ssi.annotation.PreventReplay)")
+    public void replayAspect(){
+
+    }
+
+    @Around("replayAspect()")
+    public ResponseVO doAround(ProceedingJoinPoint pjp) throws Throwable {
+        // 获取request
+        HttpServletRequest request = ServletUtils.getRequest();
+        // 时间戳
+        String sysTime = request.getParameter("sysTime");
+        long sj = System.currentTimeMillis()-Long.parseLong(sysTime);
+        // 判断客户端的时间是否超过60秒
+        if (sj/1000>=60){
+            // 超过60秒视为无效请求
+            log.error(request.getRemoteAddr()+"本次请求时间戳无效");
+            return ResponseVO.fail("本次请求时间戳无效");
+        }
+        String lk = request.getParameter("lk");
+        Object islk = LocalCache.get(lk);
+        // 校验服务端授权码
+        if (islk == null || "".equals(islk)) {
+            // 记录用户失败日志
+            log.error(request.getRemoteAddr()+"本次请求授权码无效");
+            return ResponseVO.fail("本次请求授权码无效");
+        }
+        else {
+            // 清除本地授权码存储
+            LocalCache.remove(lk);
+        }
+        // result的值就是被拦截方法的返回值
+        ResponseVO result = (ResponseVO)pjp.proceed();
+        return result;
+    }
+}

+ 15 - 14
backend/src/main/java/com/jiayue/ssi/config/WebSecurityConfig.java

@@ -44,16 +44,17 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
     CustomLogoutSuccessHandler customLogoutSuccessHandler;
     @Autowired
     JwtTokenUtil jwtTokenUtil;
-    @Autowired
-    XssEscapeFilter xssEscapeFilter;
-    @Autowired
-    XssKeywordsFilter xssKeywordsFilter;
-    @Autowired
-    SqlFilter sqlFilter;
+//    @Autowired
+//    XssEscapeFilter xssEscapeFilter;
+//    @Autowired
+//    XssKeywordsFilter xssKeywordsFilter;
+//    @Autowired
+//    SqlFilter sqlFilter;
+//    @Autowired
+//    VerifySmFilter verifySmFilter;
     @Autowired
     InterfaceLimitFilter interfaceLimitFilter;
-    @Autowired
-    VerifySmFilter verifySmFilter;
+
 
 
     @Bean
@@ -81,10 +82,10 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
     @Override
     protected void configure(HttpSecurity httpSecurity) throws Exception {
         httpSecurity.addFilterBefore(interfaceLimitFilter, LogoutFilter.class);
-        httpSecurity.addFilterBefore(verifySmFilter, LogoutFilter.class);
-        httpSecurity.addFilterBefore(xssKeywordsFilter, LogoutFilter.class);
-        httpSecurity.addFilterBefore(xssEscapeFilter, LogoutFilter.class);
-        httpSecurity.addFilterBefore(sqlFilter, LogoutFilter.class);
+        httpSecurity.addFilterBefore(new VerifySmFilter(), LogoutFilter.class);
+        httpSecurity.addFilterBefore(new XssKeywordsFilter(), LogoutFilter.class);
+        httpSecurity.addFilterBefore(new XssEscapeFilter(), LogoutFilter.class);
+        httpSecurity.addFilterBefore(new SqlFilter(), LogoutFilter.class);
         httpSecurity.addFilterBefore(new VerifyCodeFilter(), LogoutFilter.class);
         httpSecurity.addFilterBefore(new MailCodeFilter(), LogoutFilter.class);
         httpSecurity.addFilterBefore(new JwtAuthenticationTokenFilter(userServiceImpl, jwtTokenUtil), LogoutFilter.class);
@@ -98,7 +99,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .and().authorizeRequests()
 //                .antMatchers("/user/login","/captchaImage").permitAll()
                 .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
-//                .antMatchers("/getVerifyCode/**","/getMailCode/**").permitAll()
+                .antMatchers("/getVerifyCode/**","/getMailCode/**").permitAll()
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()
                 .and().headers().cacheControl();
@@ -114,6 +115,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
     public void configure(WebSecurity web) throws Exception {
         web.httpFirewall(allowUrlEncodedSlashHttpFirewall());
         /*super.configure(web);*/
-        web.ignoring().antMatchers("/static/**", "/assets/**","/getVerifyCode","/getMailCode","/sysParameterController/getUseSendMail", "/");
+        web.ignoring().antMatchers("/static/**","/assets/**","/");
     }
 }

+ 1 - 1
backend/src/main/java/com/jiayue/ssi/constant/CacheConstants.java

@@ -56,7 +56,7 @@ public class CacheConstants {
     /**
      * 是否使用邮箱口令 默认:true使用
      */
-    public static boolean use_send_mail = true;
+    public static boolean use_send_mail = false;
 
     /**
      * ip黑名单缓存

+ 22 - 0
backend/src/main/java/com/jiayue/ssi/controller/SysPolicyController.java

@@ -15,6 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * 策略配置接口
  *
@@ -125,4 +128,23 @@ public class SysPolicyController {
             throw new CustomException("策略配置保存异常", e);
         }
     }
+
+    /**
+     * 获取授权码
+     */
+    @GetMapping(value = "/getLicenseKey")
+    public ResponseVO getLicenseKey() throws CustomException {
+        try {
+            Map<String, String> map = new HashMap<>();
+            map.put("sysTime", System.currentTimeMillis()+"");
+            // 生成随机授权码
+            String lk = IdUtils.fastSimpleUUID();
+            map.put("lk", lk);
+            // 服务端保留授权码1分钟
+            LocalCache.set(lk, lk, 60000);
+            return ResponseVO.success(map);
+        } catch (Exception e) {
+            throw new CustomException("获取授权码异常", e);
+        }
+    }
 }

+ 9 - 0
backend/src/main/java/com/jiayue/ssi/controller/SysUserController.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jiayue.ssi.annotation.AgainVerify;
 import com.jiayue.ssi.annotation.InterfaceLimit;
 import com.jiayue.ssi.annotation.OperateLog;
+import com.jiayue.ssi.annotation.PreventReplay;
 import com.jiayue.ssi.backenum.ApproveOperaterEnum;
 import com.jiayue.ssi.backenum.ApproveStatusEnum;
 import com.jiayue.ssi.backenum.AuditType;
@@ -64,6 +65,7 @@ public class SysUserController {
      */
     @GetMapping(value = "/getAll")
     @PreAuthorize("@ss.hasPermi('system:user:list')")
+    @PreventReplay
     public ResponseVO getAll(String currentPage, String pageSize, String username, String phonenumber,
                              String status) throws CustomException {
         try {
@@ -165,6 +167,7 @@ public class SysUserController {
     @PostMapping(value = "/addUser")
     @OperateLog(title = "用户管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS)
     @PreAuthorize("@ss.hasPermi('system:user:add')")
+    @PreventReplay
     public ResponseVO addUser(@RequestBody SysUser user) throws CustomException {
         try {
             if (StringUtils.isEmpty(user.getUsername())) {
@@ -229,6 +232,7 @@ public class SysUserController {
     @PostMapping(value = "/updateUser")
     @OperateLog(title = "用户管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS)
     @PreAuthorize("@ss.hasPermi('system:user:edit')")
+    @PreventReplay
     public ResponseVO updateUser(@RequestBody SysUser user) throws CustomException {
         try {
             SysUser existUser = sysUserService.getById(user.getId());
@@ -317,6 +321,7 @@ public class SysUserController {
     @PostMapping(value = "/resetPassword")
     @OperateLog(title = "用户管理", businessType = BusinessType.OTHER, auditType = AuditType.SYS)
     @PreAuthorize("@ss.hasPermi('system:user:send')")
+    @PreventReplay
     public ResponseVO resetPassword(String id) {
         if (StringUtils.isEmpty(id)) {
             return ResponseVO.fail("重置密码缺失id!");
@@ -361,6 +366,7 @@ public class SysUserController {
     @AgainVerify
     @OperateLog(title = "用户管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS)
     @PreAuthorize("@ss.hasPermi('system:user:remove')")
+    @PreventReplay
     public ResponseVO delete(String id) throws CustomException {
         try {
             if (StringUtils.isEmpty(id)) {
@@ -473,6 +479,7 @@ public class SysUserController {
     @PostMapping(value = "/relockUser")
     @OperateLog(title = "用户管理", businessType = BusinessType.OTHER, auditType = AuditType.SYS)
     @PreAuthorize("@ss.hasPermi('system:user:relock')")
+    @PreventReplay
     public ResponseVO relockUser(String id) throws CustomException {
         try {
             if (StringUtils.isEmpty(id)) {
@@ -517,6 +524,7 @@ public class SysUserController {
     @PostMapping("/authRole")
     @PreAuthorize("@ss.hasPermi('system:user:role')")
     @OperateLog(title = "用户管理", businessType = BusinessType.GRANT, auditType = AuditType.SYS)
+    @PreventReplay
     public ResponseVO authRole(String userId, String roleId) throws CustomException {
         try {
             Long userid;
@@ -571,6 +579,7 @@ public class SysUserController {
      * @return
      */
     @GetMapping("/getUserRole")
+    @PreventReplay
     public ResponseVO getUserRole(Long userId) throws CustomException {
         try {
             if (userId == null) {

+ 3 - 1
backend/src/main/java/com/jiayue/ssi/filter/JwtAuthenticationTokenFilter.java

@@ -14,6 +14,7 @@ import com.jiayue.ssi.service.impl.UserServiceImpl;
 import com.jiayue.ssi.util.DateUtils;
 import com.jiayue.ssi.util.ResponseInfo;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.core.annotation.Order;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.context.SecurityContextHolder;
@@ -30,7 +31,8 @@ import com.jiayue.ssi.util.JwtTokenUtil;
  * @since 2023/02/20
  **/
 @RequiredArgsConstructor
-@Order(10)
+@Order(12)
+@Slf4j
 public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
     private String defaultFilterProcessUrl = "/user/login";
 

+ 3 - 1
backend/src/main/java/com/jiayue/ssi/filter/MailCodeFilter.java

@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
 import com.jiayue.ssi.constant.Constants;
 import com.jiayue.ssi.factory.LoginFactory;
 import com.jiayue.ssi.util.ResponseInfo;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
@@ -27,7 +28,8 @@ import lombok.RequiredArgsConstructor;
  * @since 2023/02/20
  */
 @RequiredArgsConstructor
-@Order(8)
+@Order(11)
+@Slf4j
 public class MailCodeFilter extends OncePerRequestFilter {
     private String defaultFilterProcessUrl = "/user/login";
 

+ 1 - 2
backend/src/main/java/com/jiayue/ssi/filter/SqlFilter.java

@@ -22,9 +22,8 @@ import java.util.Enumeration;
 * @since 2023/05/19
 */
 @RequiredArgsConstructor
-@Order(6)
+@Order(9)
 @Slf4j
-@Component
 public class SqlFilter  extends OncePerRequestFilter {
     @Override
     protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {

+ 3 - 1
backend/src/main/java/com/jiayue/ssi/filter/VerifyCodeFilter.java

@@ -11,6 +11,7 @@ import com.jiayue.ssi.constant.Constants;
 import com.jiayue.ssi.factory.LoginFactory;
 import com.jiayue.ssi.util.IPUtils;
 import com.jiayue.ssi.util.ResponseInfo;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
@@ -28,7 +29,8 @@ import lombok.RequiredArgsConstructor;
  * @since 2023/02/20
  */
 @RequiredArgsConstructor
-@Order(7)
+@Order(10)
+@Slf4j
 public class VerifyCodeFilter extends OncePerRequestFilter {
     private String defaultFilterProcessUrl = "/user/login";
 

+ 0 - 1
backend/src/main/java/com/jiayue/ssi/filter/VerifySmFilter.java

@@ -34,7 +34,6 @@ import java.util.Map;
 @RequiredArgsConstructor
 @Order(3)
 @Slf4j
-@Component
 public class VerifySmFilter extends OncePerRequestFilter {
     private String defaultFilterProcessUrl = "/user/login";
 

+ 1 - 2
backend/src/main/java/com/jiayue/ssi/filter/XssEscapeFilter.java

@@ -17,9 +17,8 @@ import javax.servlet.http.HttpServletResponse;
 
 //拦截请求
 @RequiredArgsConstructor
-@Order(5)
+@Order(7)
 @Slf4j
-@Component
 public class XssEscapeFilter extends OncePerRequestFilter {
     @Override
     protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) {

+ 1 - 2
backend/src/main/java/com/jiayue/ssi/filter/XssKeywordsFilter.java

@@ -22,9 +22,8 @@ import java.io.IOException;
  * @since 2023/05/16
  */
 @RequiredArgsConstructor
-@Order(4)
+@Order(5)
 @Slf4j
-@Component
 public class XssKeywordsFilter extends OncePerRequestFilter {
     @Override
     protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) {

+ 11 - 2
ui/src/layout/components/Navbar.vue

@@ -199,11 +199,20 @@ export default {
         this.$message.error('获取当前用户数据出错' + error)
       })
 
+      let sysTime
+      let lk
+      await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
+        sysTime = res.data.sysTime
+        lk = res.data.lk
+      }).catch((error) => {
+      })
       // 获取角色是否系统管理员
       const searchParams = {
-        userId: user.id
+        userId: user.id,
+        sysTime: sysTime,
+        lk: lk
       }
-      this.$axios.get('/sysUserController/getUserRole',{params: searchParams}).then((res) => {
+      await this.$axios.get('/sysUserController/getUserRole',{params: searchParams}).then((res) => {
         let userRole = res.data
         if (userRole.roleId==1){
           this.getAlarmData()

+ 1 - 1
ui/src/utils/request.js

@@ -14,7 +14,7 @@ const service = axios.create({
 })
 
 service.interceptors.request.use(
-  config => {
+  config =>  {
     const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
     // get请求映射params参数
     if (config.method === 'get' && config.params) {

+ 223 - 109
ui/src/views/sysManager/userManager/index.vue

@@ -24,18 +24,18 @@
           </el-form-item>
           <el-form-item label="用户状态" prop="status">
             <el-select
-            v-model="queryParams.status"
-            placeholder="请选择用户状态"
-            clearable
-            style="width: 240px"
-          >
-            <el-option
-              v-for="item in statusOptions"
-              :key="item.value"
-              :label="item.label"
-              :value="item.value">
-            </el-option>
-          </el-select>
+              v-model="queryParams.status"
+              placeholder="请选择用户状态"
+              clearable
+              style="width: 240px"
+            >
+              <el-option
+                v-for="item in statusOptions"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value">
+              </el-option>
+            </el-select>
           </el-form-item>
           <el-form-item>
             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@@ -266,7 +266,8 @@
 </template>
 
 <script>
-import { debounce } from 'lodash'
+import {debounce} from 'lodash'
+
 export default {
   name: "User",
   data() {
@@ -281,11 +282,11 @@ export default {
       remark: undefined,
       expDate: undefined,
       // 角色表格数据
-      jsuserid:'',
+      jsuserid: '',
       roleList: [],
-      jsusername:'',
-      jsnickname:'',
-      jsusertype:'',
+      jsusername: '',
+      jsnickname: '',
+      jsusertype: '',
       statusOptions: [
         {value: '0', label: '正常'},
         {value: '1', label: '锁定'},
@@ -330,7 +331,7 @@ export default {
         phonenumber: undefined,
         status: undefined
       },
-      edit:false,
+      edit: false,
       // 表单校验
       rules: {
         username: [
@@ -388,17 +389,32 @@ export default {
       }
       return belongTo
     },
+    /** 搜索按钮操作 */
+    handleQuery: debounce(function () {
+      this.getList()
+    }, 1000),
     /** 查询用户列表 */
-    getList(){
+    async getList() {
       this.loading = true;
+      let sysTime
+      let lk
+      await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
+        sysTime = res.data.sysTime
+        lk = res.data.lk
+      }).catch((error) => {
+        this.loading = false;
+      })
+
       var searchParams = {
         currentPage: this.currentPage,
         pageSize: this.pageSize,
         username: this.queryParams.username,
         phonenumber: this.queryParams.phonenumber,
-        status: this.queryParams.status
+        status: this.queryParams.status,
+        sysTime: sysTime,
+        lk: lk
       }
-      this.$axios.get('/sysUserController/getAll',
+      await this.$axios.get('/sysUserController/getAll',
         {params: searchParams}).then((res) => {
         this.userList = res.data.records
         this.total = res.data.total
@@ -450,10 +466,6 @@ export default {
       };
       // this.resetForm("form");
     },
-    /** 搜索按钮操作 */
-    handleQuery:debounce(function(){
-      this.getList()
-    },1000),
     /** 重置按钮操作 */
     resetQuery() {
       this.resetForm("queryForm");
@@ -461,18 +473,25 @@ export default {
     /** 新增按钮操作 */
     handleAdd() {
       this.reset();
-      this.edit=false;
+      this.edit = false;
       this.open = true;
       this.title = "添加用户";
       this.form.password = this.initPassword;
     },
     /** 提交按钮 */
-    submitForm:debounce(function(){
-      this.$refs["form"].validate(valid => {
+    submitForm: debounce(function () {
+      this.$refs["form"].validate(async valid => {
         if (valid) {
+          let sysTime
+          let lk
+          await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
+            sysTime = res.data.sysTime
+            lk = res.data.lk
+          }).catch((error) => {
+          })
           if (this.form.id != undefined) {
             // 更新操作
-            this.$axios.post('/sysUserController/updateUser', this.form).then((res) => {
+            await this.$axios.post('/sysUserController/updateUser', this.form).then((res) => {
               if (res.code == 0) {
                 this.$message.success('修改成功')
                 this.open = false;
@@ -488,13 +507,7 @@ export default {
               this.loading = false
             })
           } else {
-            // const param = {
-            //   username: this.form.username,
-            //   nickname: this.form.nickname,
-            //   phonenumber: this.form.phonenumber,
-            //   mailbox: this.form.mailbox
-            // }
-            this.$axios.post('/sysUserController/addUser', this.form).then((res) => {
+            await this.$axios.post('/sysUserController/addUser', this.form).then((res) => {
               if (res.code == 0) {
                 this.$message.success('新增成功')
                 this.open = false;
@@ -512,42 +525,69 @@ export default {
           }
         }
       });
-    },1000),
+    }, 1000),
     /** 重置密码按钮操作 */
-    handleResetPwd:debounce(function(row){
+    handleResetPwd(row) {
       this.$confirm('创建密码并发送到邮箱:' + row.mailbox, '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        const param = {
-          id: row.id
-        }
-        this.$axios.post('/sysUserController/resetPassword', param).then((res) => {
-          if (res.code == 0) {
-            this.$message({
-              type: 'success',
-              message: '创建并发送成功!'
-            });
+        type: 'warning',
+        beforeClose(action, instance, done) {
+          if (action === "confirm") {
+            instance.$refs["confirm"].$el.onclick = (function (e) {
+              e = e || window.event;
+              if (e.detail != 0) {
+                done();
+              }
+            })();
           } else {
-            this.$message({
-              type: 'error',
-              message: res.data
-            });
+            done();
           }
-        }).catch((error) => {
+        }
+      }).then(() => {
+        this.doResetPwd(row)
+      }).catch(() => {
+        //取消操作
+      });
+    },
+    doResetPwd: debounce(async function (row) {
+      let sysTime
+      let lk
+      await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
+        sysTime = res.data.sysTime
+        lk = res.data.lk
+      }).catch((error) => {
+      })
+
+      const param = {
+        id: row.id,
+        sysTime: sysTime,
+        lk: lk
+      }
+      await this.$axios.post('/sysUserController/resetPassword', param).then((res) => {
+        if (res.code == 0) {
+          this.$message({
+            type: 'success',
+            message: '创建并发送成功!'
+          });
+        } else {
           this.$message({
             type: 'error',
-            message: '创建密码失败!'
+            message: res.data
           });
-          console.log(error)
-          this.loading = false
-        })
-      }).catch(() => {
-      });
-    },500),
+        }
+      }).catch((error) => {
+        this.$message({
+          type: 'error',
+          message: '创建密码失败!'
+        });
+        console.log(error)
+        this.loading = false
+      })
+    }, 1000),
+
     /** 删除按钮操作 */
-    handleDelete(){
+    handleDelete() {
       const _selectData = this.$refs.userTable.getRadioRecord(true)
       if (_selectData == null) {
         this.$message({
@@ -556,36 +596,59 @@ export default {
         });
         return
       }
-      if (_selectData.id==1) {
+      if (_selectData.id == 1) {
         this.$message({
           type: 'warning',
           message: '内置系统管理员不能删除!'
         });
         return
       }
-      this.$prompt('请输入密码','鉴别操作',{
+      this.$prompt('请输入密码', '鉴别操作', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
-        inputType:'password',
-        inputValidator:(val)=>{
-          if (val===null || val.length<1 || val.length>20){
+        inputType: 'password',
+        inputValidator: (val) => {
+          if (val === null || val.length < 1 || val.length > 20) {
             return false;
           }
         },
-        inputErrorMessage: '不能为空,最多可录入20个字符'
-      }).then(async({value})=>{
-        this.doDelete(_selectData,value)
-      }).catch((e)=>{})
+        inputErrorMessage: '不能为空,最多可录入20个字符',
+        beforeClose(action, instance, done) {
+          if (action === "confirm") {
+            instance.$refs["confirm"].$el.onclick = (function (e) {
+              e = e || window.event;
+              if (e.detail != 0) {
+                done();
+              }
+            })();
+          } else {
+            done();
+          }
+        }
+      }).then(async ({value}) => {
+        this.doDelete(_selectData, value)
+      }).catch((e) => {
+      })
     },
     /**
      * 删除提交
      */
-    doDelete:debounce(function(_selectData,againPwd){
+    doDelete: debounce(async function (_selectData, againPwd) {
+      let sysTime
+      let lk
+      await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
+        sysTime = res.data.sysTime
+        lk = res.data.lk
+      }).catch((error) => {
+      })
+
       const param = {
         id: _selectData.id,
-        againPwd:againPwd
+        againPwd: againPwd,
+        sysTime: sysTime,
+        lk: lk
       }
-      this.$axios.post('/sysUserController/delUser', param).then((res) => {
+      await this.$axios.post('/sysUserController/delUser', param).then((res) => {
         if (res.code == 0) {
           this.$message({
             type: 'success',
@@ -605,12 +668,11 @@ export default {
         });
         this.loading = false
       })
-    },500),
+    }, 500),
     /** 修改按钮操作 */
     handleUpdate() {
       this.reset();
       let _selectData = this.$refs.userTable.getRadioRecord(true)
-      console.log(_selectData)
       if (_selectData == null) {
         this.$message({
           type: 'warning',
@@ -621,10 +683,10 @@ export default {
       this.form = _selectData;
       this.open = true;
       this.title = "修改用户";
-      this.edit=true;
+      this.edit = true;
     },
     /** 解锁按钮操作 */
-    handleRelock(){
+    handleRelock() {
       const _selectData = this.$refs.userTable.getRadioRecord(true)
       if (_selectData == null) {
         this.$message({
@@ -633,7 +695,7 @@ export default {
         });
         return
       }
-      if (_selectData.status!=='1') {
+      if (_selectData.status !== '1') {
         this.$message({
           type: 'warning',
           message: '只能对【锁定】状态的进行解锁!'
@@ -643,18 +705,40 @@ export default {
       this.$confirm('是否解锁用户?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
-        type: 'warning'
+        type: 'warning',
+        beforeClose(action, instance, done) {
+          if (action === "confirm") {
+            instance.$refs["confirm"].$el.onclick = (function (e) {
+              e = e || window.event;
+              if (e.detail != 0) {
+                done();
+              }
+            })();
+          } else {
+            done();
+          }
+        }
       }).then(() => {
         this.doRelock(_selectData)
       }).catch(() => {
+        //取消操作
       });
     },
     /**
-     * 删除提交
+     * 解锁提交
      */
-    doRelock:debounce(function(_selectData){
+    doRelock: debounce(async function (_selectData) {
+      let sysTime
+      let lk
+      await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
+        sysTime = res.data.sysTime
+        lk = res.data.lk
+      }).catch((error) => {
+      })
       const param = {
-        id: _selectData.id
+        id: _selectData.id,
+        sysTime: sysTime,
+        lk: lk
       }
       this.$axios.post('/sysUserController/relockUser', param).then((res) => {
         if (res.code == 0) {
@@ -677,16 +761,26 @@ export default {
         console.log(error)
         this.loading = false
       })
-    },1000),
-    getUserRole(userid){
+    }, 1000),
+    getUserRole(userid) {
       const a = this.$axios
-      return new Promise(function(resolve, reject) {
+      return new Promise(async function (resolve, reject) {
+        let sysTime
+        let lk
+        await a.get('/sysPolicyController/getLicenseKey').then((res) => {
+          sysTime = res.data.sysTime
+          lk = res.data.lk
+        }).catch((error) => {
+        })
+
         var userRoleParams = {
-          userId: userid
+          userId: userid,
+          sysTime: sysTime,
+          lk: lk
         }
-        a.get('/sysUserController/getUserRole',
+        await a.get('/sysUserController/getUserRole',
           {params: userRoleParams}).then(res => {
-            // 返回userRole对象
+          // 返回userRole对象
           resolve(res.data)
         })
       }).catch((error) => {
@@ -694,15 +788,25 @@ export default {
         console.error('获取用户角色出错' + error)
       })
     },
-    getRoleByType(usertype){
+    getRoleByType(usertype) {
       // 根据用户类型获取角色列表
       const a = this.$axios
       let _this = this
-      return new Promise(function(resolve, reject) {
+      return new Promise(async function (resolve, reject) {
+        let sysTime
+        let lk
+        await a.get('/sysPolicyController/getLicenseKey').then((res) => {
+          sysTime = res.data.sysTime
+          lk = res.data.lk
+        }).catch((error) => {
+        })
+
         var searchParams = {
-          usertype: usertype
+          usertype: usertype,
+          sysTime: sysTime,
+          lk: lk
         }
-        a.get('/sysRoleController/getRoleByType',
+        await a.get('/sysRoleController/getRoleByType',
           {params: searchParams}).then(res => {
           if (res.code == 0) {
             // 返回角色列表
@@ -722,32 +826,32 @@ export default {
       })
     },
     /** 分配角色操作 */
-    handleAuthRole:debounce(function(row){
+    handleAuthRole: debounce(function (row) {
       this.jsuserid = row.id
       this.jsusername = row.username
       this.jsnickname = row.nickname
       this.jsopen = true;
       this.title = "分配角色";
 
-      Promise.all([this.getRoleByType(row.usertype),this.getUserRole(this.jsuserid)]).then((res) => {
-        if (res[1]!='' && res[1]!=undefined){
+      Promise.all([this.getRoleByType(row.usertype), this.getUserRole(this.jsuserid)]).then((res) => {
+        if (res[1] != '' && res[1] != undefined) {
           const roleTable = this.$refs.xTable.getTableData()
-          for (var i=0;i<roleTable.tableData.length;i++){
-            if (res[1].roleId==roleTable.tableData[i].roleId){
+          for (var i = 0; i < roleTable.tableData.length; i++) {
+            if (res[1].roleId == roleTable.tableData[i].roleId) {
               // 将原有的角色勾选上
               this.$refs.xTable.setCheckboxRow(roleTable.tableData[i], true)
             }
           }
         }
-      }).catch(e=>{
+      }).catch(e => {
         this.loading = false
-        this.$message.error("获取分配角色异常:"+e)
+        this.$message.error("获取分配角色异常:" + e)
       })
-    },1000),
+    }, 1000),
     /** 角色分配提交按钮 */
-    jssubmitForm:debounce(function(){
+    jssubmitForm: debounce(async function () {
       const _selectData = this.$refs.xTable.getCheckboxRecords(true)
-      if (_selectData.length>1){
+      if (_selectData.length > 1) {
         this.$message({
           type: 'warning',
           message: '每个用户只能分配一个角色!'
@@ -755,22 +859,32 @@ export default {
         return
       }
       let roleid = '';
-      if (_selectData.length==1){
+      if (_selectData.length == 1) {
         roleid = _selectData[0].roleId
-      }
-      else{
+      } else {
         this.$message({
           type: 'warning',
           message: '请选择角色!'
         });
         return
       }
+
+      let sysTime
+      let lk
+      await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
+        sysTime = res.data.sysTime
+        lk = res.data.lk
+      }).catch((error) => {
+      })
+
       // 提交后台角色分配
       const param = {
         userId: this.jsuserid,
-        roleId:  roleid
+        roleId: roleid,
+        sysTime: sysTime,
+        lk: lk
       }
-      this.$axios.post('/sysUserController/authRole', param).then((res) => {
+      await this.$axios.post('/sysUserController/authRole', param).then((res) => {
         if (res.code == 0) {
           this.$message({
             type: 'success',
@@ -790,7 +904,7 @@ export default {
         });
         this.loading = false
       })
-    },1000)
+    }, 1000)
   }
 };
 </script>