LoginByUsername()

in front-end/src/store/modules/user.js [67:88]


    LoginByUsername({ commit }, userInfo) {
      const username = userInfo.username.trim()
      return new Promise((resolve, reject) => {
        loginByUsername(username, userInfo.password).then(response => {
          if (response.data.hasOwnProperty('error') && response.data.error.length >= 0) {
            Message({
              message: 'The username or password is incorrect',
              type: 'error',
              duration: 5 * 1000
            })
            reject('login error')
          }
          commit('SET_TOKEN', response.headers.token)
          setToken(response.headers.token)
          setName(response.headers.username)
          setTenant(response.headers.tenant)
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    },