server/api/students/students.controller.js
/**
 * Only available in development mode. Login as a user given their ID.
 *
 * @param {Koa session} ctx
 **/
Only available in development mode. Login as a user given their ID.
@param {Koa session} ctx
Only available in development mode . Login as a user given their ID . @param { Koa session } ctx
async function loginAs (ctx) {
  if (ctx.state.env !== 'development') {
    return ctx.forbidden('Not in development mode.');
  }
  const rcsID = ctx.request.query.rcs_id;
  ctx.session.cas_user = rcsID;
  logger.info(`Logging in as ${rcsID}`);
  let student = await Student.findOne()
    .byUsername(ctx.session.cas_user.toLowerCase())
    .exec();
  if (!student) {
    student = Student({
      rcs_id: ctx.session.cas_user,
      joined_date: new Date(),
      last_login: new Date()
    });
    await student.save();
    logger.info('Created new user for testing.');
  }
  ctx.state.user = student;
  await getUser(ctx);
}
async function loginAs ( ctx ) { if ( ctx . state . env !== 'development' ) { return ctx . forbidden ( 'Not in development mode.' ) ; } const rcsID = ctx . request . query . rcs_id ; ctx . session . cas_user = rcsID ; logger . info ( ` ${ rcsID } ` ) ; let student = await Student . findOne ( ) . byUsername ( ctx . session . cas_user . toLowerCase ( ) ) . exec ( ) ; if ( ! student ) { student = Student ( { rcs_id : ctx . session . cas_user , joined_date : new Date ( ) , last_login : new Date ( ) } ) ; await student . save ( ) ; logger . info ( 'Created new user for testing.' ) ; } ctx . state . user = student ; await getUser ( ctx ) ; }
Only available in development mode.
Only available in development mode .