'use strict';

module.exports = (options, app) => {
  return async function(ctx, next) {
    // const { cookies } = ctx;
    if(options.type == 'new'){//node新框架下的登录判断
      if(!ctx.appUserId || !ctx.deviceId || !ctx.deviceLoginId || !ctx.userId){
        const msg = 'bad request';
        ctx.throw(403, msg);
        return;
      }
    }

    if(options.type == 'old'){//php老框架下登录判断
      if (!ctx.user_sid) {
        const msg = 'bad request';
        ctx.throw(403, msg);
        return;
      }
    }
    await next();
  };
};
