How to use the ember-simple-auth/test-support.authenticateSession function in ember-simple-auth

To help you get started, we’ve selected a few ember-simple-auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ilios / frontend / tests / helpers / setup-authentication.js View on Github external
export default async function(userObject = {id: defaultUserId}, performsNonLearnerFunction = false) {
  const userId = (userObject && 'id' in userObject) ? userObject.id : defaultUserId;
  const jwtObject = {
    'user_id': userId
  };
  if (performsNonLearnerFunction) {
    jwtObject['performs_non_learner_function'] = true;
  }
  const encodedData =  window.btoa('') + '.' +  window.btoa(JSON.stringify(jwtObject)) + '.';
  const token = {
    jwt: encodedData
  };
  const { server } = getContext();
  await authenticateSession(token);

  if (userObject) {
    const properties = Object.assign({id: userId}, userObject);
    const user = server.create('user', properties);
    server.create('authentication', {id: user.id, user});
    return user;
  }

  return null;
}
github HospitalRun / hospitalrun-frontend / tests / helpers / authenticate-user.js View on Github external
export function authenticateUser(attrs = {}) {
  let expiresAt = new Date().getTime() + 600000;
  return authenticateSession(merge({
    name: 'hradmin',
    roles: ['System Administrator', 'admin', 'user'],
    expires_at: expiresAt,
    role: 'System Administrator',
    prefix: 'p1'
  }, attrs));
}