Can someone help me to figure out why this code does not work?
services/auth.js
import {
CognitoUserPool,
CognitoUserAttribute,
CognitoUser,
AuthenticationDetails
} from 'react-native-aws-cognito-js';
const COGNITO_POOL = new CognitoUserPool({
region: 'us-west-1',
IdentityPoolId: '****',
UserPoolId: '****',
ClientId: '****',
})
export const signIn = (data) => {
const authenticationDetails = new AuthenticationDetails({
Username: data.login,
Password: data.password
});
const cognitoUser = new CognitoUser({
Username: data.login,
Pool: COGNITO_POOL
});
return new Promise( (resolve, reject) => {
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: (result) => {
console.log(result);
resolve('access token + ' + result.getAccessToken().getJwtToken());
},
onFailure: (err) => {
console.log('onFailure', err)
},
mfaRequired: (codeDeliveryDetails) => {
console.log('mfaRequired', codeDeliveryDetails)
}
})
})
}
sagas/auth.js
import {
LOGIN_REQUEST,
SET_AUTH,
} from 'actions/types';
import { take, call, put, race } from 'redux-saga/effects';
import * as AuthService from 'services/auth';
const signIn = function* signIn() {
while (true) {
const request = yield take(LOGIN_REQUEST);
try {
response = yield call(AuthService.signIn, { login: request.data.login, password: request.data.password });
} catch (error) {
return false;
}
yield put({ type: SET_AUTH, response });
}
}
export {
signIn,
}
All functions seems to work, but I don't see any HTTP requests in Charles proxy; I put some console.log
into cognitoUser.authenticateUser()
function - it fires, but nothing happens. No errors in console, nothing. What could be wrong?
Thanks a lot.