2016-06-14 10 views
0

나는 Amazon Cognito User Pools을 사용 중입니다. 사용자를 인증하려고합니다. 먼저 사용자는 전화 번호와 암호를 입력해야합니다. 사용자 인증을 위해 에 phonenumberpassword을 입력하면 사용자를 인증하기 위해 SMS가 전송됩니다. 사용자가 앱을 나는 사용자가 필요없이 응용 프로그램을 사용하여 진행하려는 배경에 간 경우 응용 프로그램Amazon Cognito를 사용하여 사용자 로그인

2)에 등록되어 있지 않은 경우 나 사용자 등록 화면을 팝업 할

1.

) 다시 로그인하십시오. (사용자가 배경으로 이동할 때마다 항상 로그인해야합니다.)

3. 사용자가 SMS 유효성을 등록했지만 인증하지 않은 경우 사용자를 확인 페이지

으로 리디렉션하고 싶습니다.

저는 지금 거의 일주일 동안 붙어 있습니다. 누군가 나를 도울 수 있습니까?

앱 위임에 다음 코드가 있습니다. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

..

 AWSServiceConfiguration *serviceConfiguration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; 



     //create a pool 

     AWSCognitoIdentityUserPoolConfiguration *configuration = [[AWSCognitoIdentityUserPoolConfiguration alloc] initWithClientId:@"XXX" clientSecret:@"XXX" poolId:@"us-east-1_XXX"]; 

     [AWSCognitoIdentityUserPool registerCognitoIdentityUserPoolWithConfiguration:serviceConfiguration userPoolConfiguration:configuration forKey:@"UserPool"]; 

     //AWSCognitoIdentityUserPool *pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:@"UserPool"]; 





     [AWSLogger defaultLogger].logLevel = AWSLogLevelVerbose; 





     AWSCognitoIdentityUserPool *pool =[AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:@"UserPool"]; 



     pool.delegate = self; 

} 



//set up password authentication ui to retrieve username and password from the user 

-(id<AWSCognitoIdentityPasswordAuthentication>) startPasswordAuthentication { 

//  

    if(!self.navController){ 

     self.navController = [[UIForViewController getStoryboard] instantiateViewControllerWithIdentifier:@"signupSegueID"]; 

    } 

// if(!self.signInViewController){ 

//  self.signInViewController = self.navigationController.viewControllers[0]; 

// } 



    dispatch_async(dispatch_get_main_queue(), ^{ 

     //rewind to login screen 



     //display login screen if it isn't already visibile 

     if(!(self.navController.isViewLoaded && self.navController.view.window)) 

     { 

      [self.window.rootViewController presentViewController:self.navController animated:YES completion:nil]; 

     } 

    }); 

    return nil; 


} 

내가 현재 확인하기 위해 API를 노출하지 않습니다 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

[[self.user getDetails] continueWithSuccessBlock:^id _Nullable(AWSTask<AWSCognitoIdentityUserGetDetailsResponse *> * _Nonnull task) { 
    if (task.error) { 
     // 
     NSLog(@"Error "); 
     [[[UIAlertView alloc] initWithTitle:task.error.userInfo[@"__type"] 
            message:task.error.userInfo[@"message"] 
            delegate:self 
          cancelButtonTitle:@"Ok" 
          otherButtonTitles:nil] show]; 
     return nil; 
    } 
    AWSCognitoIdentityUserGetDetailsResponse *response = task.result; 



    for (AWSCognitoIdentityUserAttributeType *attribute in response.userAttributes) { 
     //print the user attributes 
     NSLog(@"Attribute: %@ Value: %@", attribute.name, attribute.value); 
    } 
    return nil; 
}]; 

답변

0

1) Cognito APPDELEGATES에 다음 코드를 추가하지 않는 startPasswordAuthentication이 실행되지 않습니다주의하시기 바랍니다 사용자 이름이 이미 존재하는 경우. 이 문제를 해결하려면 사용자 이름 별 API를 호출하고 예외가 발생했을 때이를 바탕으로 조치를 취할 수 있습니다. 더 로컬에서 생각하고있는 경우 사용자 이름을 기반으로 세션을 확인하여 다른 사람이 이미 로그인했는지 확인할 수 있습니다. 012) 2) RefreshTokens API는 이전 액세스가 만료 된 후에 새 액세스 토큰을 얻는 데 사용됩니다. 이를 용이하게하기 위해 인증시 다시 가져온 새로 고침 토큰을 사용하십시오.

3) 등록 되어도 액세스 권한이 부여되지 않습니다. 사용자 등록시에는 토큰이 없지만 나중에 로그인해야합니다. 이것은 이미 처리되었습니다.