king
2022-04-27 1072f0d4d3390d4b4923f3c7e407731817660780
src/views/login/index.jsx
@@ -17,6 +17,7 @@
const LoginForm = asyncLoadComponent(() => import('./loginform'))
const Resetpwd = asyncLoadComponent(() => import('@/components/header/resetpwd'))
const LoginCloudForm = asyncComponent(() => import('./logincloudform'))
const LoginCodeForm = asyncComponent(() => import('./logincodeform'))
const iszhCN = sessionStorage.getItem('lang') !== 'en-US'
const _href = window.location.href.split('#')[0]
@@ -103,6 +104,16 @@
        localStorage.setItem(_href, window.btoa(window.encodeURIComponent(JSON.stringify({username: param.username, password: param.password}))))
      } else {
        localStorage.removeItem(_href)
      }
      // positecgroup
      if (res.token) {
        this.setState({
          isDisabled: false,
          verify: {...res, $password: param.password},
          codeVisible: true
        })
        return
      }
      let level = localStorage.getItem(_href + 'pwdlevel')
@@ -512,10 +523,10 @@
        Api.getSystemConfig(_param).then(res => {
          if (res.status) {
            // positecgroup
            // res.Banner = res.Banner ? res.Banner.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
            // res.doclogo = res.doclogo ? res.doclogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
            // res.indexlogo = res.indexlogo ? res.indexlogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
            // res.loginlogo = res.loginlogo ? res.loginlogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
            res.Banner = res.Banner ? res.Banner.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
            res.doclogo = res.doclogo ? res.doclogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
            res.indexlogo = res.indexlogo ? res.indexlogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
            res.loginlogo = res.loginlogo ? res.loginlogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : ''
            let _url = _href + 'system'
            let systemMsg = {
@@ -624,32 +635,32 @@
            }
            // positecgroup
            // if (res.users_upt === 'true' && window.GLOB.systemType === 'production') {
            //   Api.getLocalConfig ({
            //     func: 's_Get_local_u_deleted',
            //     users_upt_date: res.users_upt_date,
            //     userid: result.UserID,
            //     LoginUID: result.LoginUID
            //   }).then(localres => {
            //     if (!localres.status) return
            //     Api.getSystemConfig({
            //       func: 's_get_sso_u_create',
            //       user_ids: localres.user_ids,
            //       user_ids_local: localres.user_ids_local,
            //       users_upt_date: localres.users_upt_date,
            //       userid: result.UserID,
            //       LoginUID: result.LoginUID
            //     }).then(ssores => {
            //       if (!ssores.status) return
            //       Api.getLocalConfig ({
            //         func: 's_get_local_u_create',
            //         user_ids_local: ssores.user_ids_local,
            //         userid: result.UserID,
            //         LoginUID: result.LoginUID
            //       })
            //     })
            //   })
            // }
            if (res.users_upt === 'true' && window.GLOB.systemType === 'production') {
              Api.getLocalConfig ({
                func: 's_Get_local_u_deleted',
                users_upt_date: res.users_upt_date,
                userid: result.UserID,
                LoginUID: result.LoginUID
              }).then(localres => {
                if (!localres.status) return
                Api.getSystemConfig({
                  func: 's_get_sso_u_create',
                  user_ids: localres.user_ids,
                  user_ids_local: localres.user_ids_local,
                  users_upt_date: localres.users_upt_date,
                  userid: result.UserID,
                  LoginUID: result.LoginUID
                }).then(ssores => {
                  if (!ssores.status) return
                  Api.getLocalConfig ({
                    func: 's_get_local_u_create',
                    user_ids_local: ssores.user_ids_local,
                    userid: result.UserID,
                    LoginUID: result.LoginUID
                  })
                })
              })
            }
          } else {
            message.warning(res.message)
          }
@@ -753,6 +764,66 @@
        }
      })
    })
  }
  codeSubmit = () => {
    const { verify } = this.state
    this.codeRef.handleConfirm().then(res => {
      this.setState({
        codeLoading: true
      })
      Api.verifycode({...verify, code: res.code}).then(result => {
        this.setState({
          codeVisible: false,
          codeLoading: false
        })
        if (result.verifyResult === 'success') {
          let level = localStorage.getItem(_href + 'pwdlevel')
          if (level) {
            let visible = false
            let tip = '密码强度不够,请修改密码!'
            if (verify.$password.length < 8) {
              visible = true
            } else if (level === 'letter_num' && /^([^0-9]*|[^a-zA-Z]*)$/.test(verify.$password)) {
              visible = true
            } else if ((level === 'char_num' || level === 'char_num_90') && /^([^0-9]*|[^a-zA-Z]*|[^!@#$%^&*()_]*)$/.test(verify.$password)) {
              visible = true
            } else if (level === 'char_num_90' && verify.modifydate) {
              let s = (new Date().getTime() - new Date(verify.modifydate).getTime()) / (1000 * 24 * 60 * 60)
              if (!isNaN(s) && s > 90) {
                visible = true
                tip = '您已90天未修改密码,请更换密码后使用!'
              }
            }
            if (visible) {
              message.warning(tip)
              this.setState({
                isDisabled: false,
                visible: true
              })
              return
            }
          }
          let _history = sessionStorage.getItem('history')
          if (_history) {
            sessionStorage.removeItem('history')
            // 查看是否为其他页面跳转,路径存在时,跳回原页面
            this.props.history.replace(_history)
          } else {
            this.props.history.replace('/main')
          }
        } else {
          notification.warning({
            top: 92,
            message: '验证码无效,请重新登录!',
            duration: 5
          })
        }
      })
    }, () => {})
  }
  resetPwdSubmit = () => {
@@ -862,12 +933,27 @@
          cancelText={this.state.dict['login.cancel']}
          visible={this.state.visible}
          onOk={this.resetPwdSubmit}
          maskClosable={false}
          confirmLoading={this.state.resetLoading}
          onCancel={() => this.setState({visible: false, resetLoading: false})}
          destroyOnClose
        >
          <Resetpwd wrappedComponentRef={(inst) => this.formRef = inst} resetPwdSubmit={this.resetPwdSubmit}/>
        </Modal>
        {/* 二次验证 */}
        <Modal
          title="二次验证"
          okText={this.state.dict['login.ok']}
          cancelText={this.state.dict['login.cancel']}
          visible={this.state.codeVisible}
          onOk={this.codeSubmit}
          maskClosable={false}
          confirmLoading={this.state.codeLoading}
          onCancel={() => this.setState({codeVisible: false, codeLoading: false})}
          destroyOnClose
        >
          <LoginCodeForm verify={this.state.verify} wrappedComponentRef={(inst) => this.codeRef = inst} handleSubmit={this.codeSubmit}/>
        </Modal>
      </div>
    )
  }