signInWithEmailAndPassword method
Tries to sign in a user with the given email address and password.
Implementation
Future<ShopifyUser> signInWithEmailAndPassword({
required String email,
required String password,
}) async {
final AccessTokenWithExpDate accessTokenWithExpDate =
await _createAccessToken(email, password);
if (accessTokenWithExpDate.accessToken == null) {
throw Exception('Invalid credentials');
}
final WatchQueryOptions _getCustomer = WatchQueryOptions(
document: gql(getCustomerQuery),
variables: {'customerAccessToken': accessTokenWithExpDate.accessToken},
fetchPolicy: ShopifyConfig.fetchPolicy,
);
final QueryResult result = await _graphQLClient!.query(_getCustomer);
checkForError(result);
final shopifyUser = ShopifyUser.fromGraphJson(result.data!['customer']);
await _setShopifyUser(accessTokenWithExpDate, shopifyUser);
return shopifyUser;
}