also arbeite ich mit AWS cognito, und ich bin ein bisschen verwirrt, wie man das Passwort bekommen?Wie bekomme ich ein Passwort von aws cognito - android?
Wenn ein Benutzer ein Passwort in einen Bearbeitungstext eingibt, wie erhalte ich das Passwort, das der Benutzer bei der Anmeldung eingegeben hat, damit ich das Passwort mit dem registrierten Passwort vergleichen kann?
Hier ist der Code ich mein Benutzer registrieren musste:
userPool.signUpInBackground(username_ET.getText().toString(), password_ET.getText().toString(), userAttributes, null, signupCallback);
Und hier ist der Code, den ich verwendet, um sich einzuloggen:
private AuthenticationHandler authenticationHandler = new AuthenticationHandler()
{
@Override
public void onSuccess(CognitoUserSession userSession, CognitoDevice newDevice)
{
Log.d(COGNITO_LOGIN,"Login success I think?!");
cognitoUser.getDetailsInBackground(getDetailsHandler);
//Here i need to compare passwords before i can move on.
}
@Override
public void getAuthenticationDetails(AuthenticationContinuation authenticationContinuation, String userId)
{
Log.d(COGNITO_LOGIN,passwordET.getText().toString());
// The API needs user sign-in credentials to continue
AuthenticationDetails authenticationDetails = new AuthenticationDetails(userId, passwordET.getText().toString(), null);
// Pass the user sign-in credentials to the continuation
authenticationContinuation.setAuthenticationDetails(authenticationDetails);
// Allow the sign-in to continue
authenticationContinuation.continueTask();
}
@Override
public void getMFACode(MultiFactorAuthenticationContinuation multiFactorAuthenticationContinuation) {
// Multi-factor authentication is required; get the verification code from user
multiFactorAuthenticationContinuation.setMfaCode("verificationCode");
// Allow the sign-in process to continue
multiFactorAuthenticationContinuation.continueTask();
}
@Override
public void authenticationChallenge(ChallengeContinuation continuation) {
}
@Override
public void onFailure(Exception exception)
{
// Sign-in failed, check exception for the cause
Log.d(COGNITO_LOGIN,"Login failed!");
Log.d(COGNITO_LOGIN,exception.getMessage());
exceptionMessage(exception.getMessage());
}
};
cognitoUser.getSessionInBackground(authenticationHandler);
Mit dem Authentifizierungs-Handler, ich muss nur passieren im richtigen Benutzernamen (oder userID), um den onSuccess auszuführen. Passwort ist nicht einmal erforderlich. Also ich bin verwirrt, wo der Benutzer auch das richtige Passwort eingeben muss, damit sie sich einloggen.
Ich bin mir nicht sicher, ob ich das verstehe. Sie geben das Passwort in dem gerade angegebenen Code ein. Wenn Sie AuthenticationDetails erstellen und zur Fortsetzung hinzufügen. Was genau ist deine Frage? – doorstuck
@doorstuck Ja, ich habe das Passwort angegeben, aber die Log-Anweisung in 'getgetAuthenticationDetails' wird nicht ausgeführt. und wenn ich ein falsches Passwort einlogge, loggt es sich trotzdem ein – TheQ
versuche, das Abmelden anzurufen oder die App neu zu installieren. Dann werden die Anmeldeinformationen nicht gespeichert und das Passwort wird mit der Methode 'getAuthenticationDetails' abgefragt. – doorstuck