text: // import  passport from 'koa-passport'
  // import LocalStrategy from 'passport-local'
  // import UserSchema from '../../dbs/models/users'
  
  const passport = require('koa-passport')
  const LocalStrategy = require('passport-local')
  const UserSchema = require('../../dbs/models/users')
  
  passport.use(new LocalStrategy(async function(username, password, done) {
    let where = {
      username
    };
    let result = await UserSchema.findOne(where)
    if(result!=null) {
      if(result.password === password) {
        return done(null, result);
      }else {
        return done(null, false, '密码错误');
      }
    }else {
      return done(null, false, '用户不存在');
    }
  }))
  
  //使用session 序列化
  passport.serializeUser(function (user, done){
    done(null, user)
  })
  //反序列化
  passport.deserializeUser(function(user, done){
    return done(null, user)
  })
  
  // export default passport
  module.exports=passport