Quellcode durchsuchen

变更重审验证码更改

laiguoran vor 4 Jahren
Ursprung
Commit
2c8e6fb347
2 geänderte Dateien mit 23 neuen und 10 gelöschten Zeilen
  1. 12 7
      app/controller/change_controller.js
  2. 11 3
      app/view/change/info_modal.ejs

+ 12 - 7
app/controller/change_controller.js

@@ -778,13 +778,18 @@ module.exports = app => {
                 if (changeData.status !== audit.flow.status.checked || ctx.session.sessionUser.accountId !== auditInfo.uid) {
                     throw '您无权进行该操作';
                 }
-                const code = ctx.request.body.code;
-                const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
-                const cacheKey = 'smsCode:' + ctx.session.sessionUser.accountId;
-                const cacheCode = await app.redis.get(cacheKey);
-                // console.log(cacheCode);
-                if (cacheCode === null || code === undefined || cacheCode !== (code + pa.auth_mobile)) {
-                    throw '验证码不正确!';
+                if (ctx.session.sessionUser.loginStatus === 0) {
+                    const code = ctx.request.body.code;
+                    const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
+                    if (!pa.auth_mobile) {
+                        throw '未绑定手机号';
+                    }
+                    const cacheKey = 'smsCode:' + ctx.session.sessionUser.accountId;
+                    const cacheCode = await app.redis.get(cacheKey);
+                    // console.log(cacheCode);
+                    if (cacheCode === null || code === undefined || cacheCode !== (code + pa.auth_mobile)) {
+                        throw '验证码不正确!';
+                    }
                 }
 
                 // 重新审批

+ 11 - 3
app/view/change/info_modal.ejs

@@ -692,7 +692,7 @@
     </div>
 </div>
 <% if (auditStatus === 4 && ctx.session.sessionUser.accountId === auditList[auditList.length-1].uid && stageChangeNum === 0) { %>
-<% if (!authMobile) { %>
+<% if (!authMobile && ctx.session.sessionUser.loginStatus === 0) { %>
     <!--终审重新审批-->
     <div class="modal fade" id="sp-down-back" data-backdrop="static">
         <div class="modal-dialog" role="document">
@@ -721,6 +721,7 @@
             </div>
             <div class="modal-body">
                 <h5>确认由「终审-<%= auditList[auditList.length-1].name %>」重新审批「<%= change.code %>」?</h5>
+                <% if (ctx.session.sessionUser.loginStatus === 0) { %>
                 <div class="form-group">
                     <label>重审需要验证码确认,验证码将发送至尾号<%- authMobile.slice(-4) %>的手机</label>
                     <div class="input-group input-group-sm mb-3">
@@ -730,12 +731,13 @@
                         </div>
                     </div>
                 </div>
+                <% } %>
             </div>
             <div class="modal-footer">
                 <input type="hidden" name="cid" value="<%= change.cid %>">
                 <input type="hidden" name="_csrf" value="<%= ctx.csrf %>" />
                 <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
-                <button type="button" id="re-shenpi-btn" class="btn btn-warning btn-sm" disabled>确定重审</button>
+                <button type="button" id="re-shenpi-btn" class="btn btn-warning btn-sm" <% if (ctx.session.sessionUser.loginStatus === 0) { %>disabled<% } %>>确定重审</button>
             </div>
         </form>
     </div>
@@ -789,6 +791,10 @@
     });
 
     $('#re-shenpi-btn').click(function () {
+        const data = {
+            cid: '<%- change.cid %>',
+        };
+        <% if (ctx.session.sessionUser.loginStatus === 0) { %>
         const code = $("#againForm input[name='code']").val();
         if ($(this).hasClass('disabled')) {
             return false;
@@ -798,10 +804,12 @@
             toast('请填写正确的验证码', 'error');
             return false;
         }
+        data.code = code;
+        <% } %>
         $.ajax({
             url: '/tender/<%- tender.id %>/change/check/again?_csrf=' + csrf,
             type: 'post',
-            data: { code: code, cid: '<%- change.cid %>' },
+            data: data,
             dataTye: 'json',
             success: function(response) {
                 if (response.err === 0) {