Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing exception with authenticateUser #46

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion lib/sig_v4.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const _x_amz_date = 'x-amz-date';
const _x_amz_security_token = 'x-amz-security-token';
const _host = 'host';
const _authorization = 'Authorization';
const _default_content_type = 'application/json';
const _default_content_type = 'application/json; charset=utf-8';
const _default_accept_type = 'application/json';

class AwsSigV4Client {
Expand Down
6 changes: 3 additions & 3 deletions lib/src/cognito_credentials.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class CognitoCredentials {
}

/// Get AWS Credentials for authenticated user
Future<void> getAwsCredentials(token) async {
Future<void> getAwsCredentials(token, [String authenticator]) async {
if (expireTime == null ||
new DateTime.now().millisecondsSinceEpoch > expireTime - 60000) {
final identityId = new CognitoIdentityId(_identityPoolId, _pool);
final identityIdId = await identityId.getIdentityId(token);
final identityIdId = await identityId.getIdentityId(token, authenticator);

final authenticator = 'cognito-idp.$_region.amazonaws.com/$_userPoolId';
authenticator ??= 'cognito-idp.$_region.amazonaws.com/$_userPoolId';
final Map<String, String> loginParam = {
authenticator: token,
};
Expand Down
4 changes: 2 additions & 2 deletions lib/src/cognito_identity_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class CognitoIdentityId {
}

/// Get AWS Identity Id for authenticated user
Future<String> getIdentityId(token) async {
Future<String> getIdentityId(token, [String authenticator]) async {
final identityIdKey = 'aws.cognito.identity-id.$_identityPoolId';
String identityId = await _pool.storage.getItem(identityIdKey);
if (identityId != null) {
this.identityId = identityId;
return identityId;
}
final authenticator = 'cognito-idp.$_region.amazonaws.com/$_userPoolId';
authenticator ??= 'cognito-idp.$_region.amazonaws.com/$_userPoolId';
final Map<String, String> loginParam = {
authenticator: token,
};
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cognito_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class CognitoUser {
['DeviceKey'];
await cacheDeviceKeyAndPassword();

if (dataConfirm['UserConfirmationNecessary'] == true) {
if (dataConfirm['UserConfirmationNecessary'] == true && !_signInUserSession.isValid()) {
throw new CognitoUserConfirmationNecessaryException(
signInUserSession: _signInUserSession);
}
Expand Down