无法通过AWS Cognito进行身份验证

时间:2018-02-05 18:01:11

标签: javascript reactjs amazon-web-services react-native amazon-cognito

有人可以帮我弄清楚为什么这段代码不起作用?

服务/ auth.js

let x = (i > Math.floor(size / 2)) ? (size - 1) * 2 - b : hexagonArraySize(i) - b - 1
        |                          |                    |
        |       check index        |     second half    |          first half

传奇/ 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)
      }
    })
  })
}

所有功能似乎都有效,但我在Charles代理中看不到任何HTTP请求;我将一些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, } 放入console.log函数中 - 它会触发,但没有任何反应。控制台没有错误,没有。可能有什么不对?

非常感谢。

0 个答案:

没有答案