login.js 508 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
const { preLogin, postLogin } = require('../../lib/utils/login')

module.exports = async function (params = {}) {
  const schema = {
    unieid: 'username'
  }

  this.middleware.validate(params, schema)

  const {
    unieid
  } = params

  const user = await preLogin.call(this, {
    user: {
      username: unieid
    }
  })

  const result = await postLogin.call(this, {
    user
  })

  return {
    errCode: result.errCode,
    newToken: result.newToken,
    unieid
  }
}