How to use the @expo/xdl.UserManager.loginAsync function in @expo/xdl

To help you get started, we’ve selected a few @expo/xdl 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 expo / expo-cli / packages / expo-cli / src / accounts.ts View on Github external
if (val.trim() === '') {
          return false;
        }
        return true;
      },
    });
  }

  const answers = await prompt(questions);

  const data = {
    username: username || answers.username,
    password: password || answers.password,
  };

  let user = await UserManager.loginAsync('user-pass', data);

  if (user) {
    console.log(`\nSuccess. You are now logged in as ${chalk.green(user.username)}.`);
    return user;
  } else {
    throw new Error('Unexpected Error: No user returned from the API');
  }
}
github expo / expo / tools / expotools / src / Fixtures.ts View on Github external
async function _loginAsCorrectUserAsync(): Promise {
  const username = process.env.EXPO_HOME_DEV_ACCOUNT_USERNAME;
  if (!username) {
    throw new Error('EXPO_HOME_DEV_ACCOUNT_USERNAME must be set in your environment.');
  }
  const password = process.env.EXPO_HOME_DEV_ACCOUNT_PASSWORD;
  if (!password) {
    throw new Error('EXPO_HOME_DEV_ACCOUNT_PASSWORD must be set in your environment.');
  }

  await UserManager.loginAsync('user-pass', {
    username,
    password,
  });
}
github expo / turtle / src / bin / utils / user.ts View on Github external
export async function ensureUserLoggedIn(userData: IUserData) {
  const currentUser = await UserManager.getCurrentUserAsync();
  if (currentUser) {
    return currentUser;
  } else if (!userData.username || !userData.password) {
    throw new ErrorWithProgramHelp('Please provide username and password');
  } else {
    try {
      return await UserManager.loginAsync('user-pass', userData);
    } catch (err) {
      throw new Error('Failed to log in with provided username and password');
    }
  }
}