mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
Merge pull request #45 from ClaytonWWilson/PasswordReset
Add backend password reset functionality
This commit is contained in:
commit
98eadc6a70
@ -5,6 +5,7 @@ import com.amplifyframework.auth.AuthException;
|
||||
import com.amplifyframework.auth.AuthSession;
|
||||
import com.amplifyframework.auth.cognito.AWSCognitoAuthSession;
|
||||
import com.amplifyframework.auth.options.AuthSignUpOptions;
|
||||
import com.amplifyframework.auth.result.AuthResetPasswordResult;
|
||||
import com.amplifyframework.auth.result.AuthSignInResult;
|
||||
import com.amplifyframework.auth.result.AuthSignUpResult;
|
||||
import com.amplifyframework.core.Amplify;
|
||||
@ -21,6 +22,7 @@ public class AuthManager {
|
||||
AWSCognitoAuthSession authSession = null;
|
||||
AuthSignUpResult authSignUpResult = null;
|
||||
AuthSignInResult authSignInResult = null;
|
||||
AuthResetPasswordResult authResetPasswordResult = null;
|
||||
AuthException authError = null;
|
||||
String email = null;
|
||||
String password = null;
|
||||
@ -90,10 +92,19 @@ public class AuthManager {
|
||||
waiting = false;
|
||||
}
|
||||
|
||||
public void setAuthResetPasswordResult(AuthResetPasswordResult toSet) {
|
||||
authResetPasswordResult = toSet;
|
||||
waiting = false;
|
||||
}
|
||||
|
||||
public void signOutSuccess() {
|
||||
waiting = false;
|
||||
}
|
||||
|
||||
public void passwordResetSuccess() {
|
||||
waiting = false;
|
||||
}
|
||||
|
||||
public void startSignUp(String email, String password) throws AuthException {
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
@ -145,6 +156,19 @@ public class AuthManager {
|
||||
throwIfAuthError();
|
||||
}
|
||||
|
||||
public void changePassword(String email) throws AuthException {
|
||||
this.email = email;
|
||||
waiting = true;
|
||||
Amplify.Auth.resetPassword(email, result -> setAuthResetPasswordResult(result), error -> setAuthError(error));
|
||||
throwIfAuthError();
|
||||
}
|
||||
|
||||
public void confirmPasswordReset(String newPassword, String confirmationCode) throws AuthException {
|
||||
waiting = true;
|
||||
Amplify.Auth.confirmResetPassword(newPassword, confirmationCode, this::passwordResetSuccess, this::setAuthError);
|
||||
throwIfAuthError();
|
||||
}
|
||||
|
||||
public static Properties loadProperties(Context context, String path) throws IOException, JSONException {
|
||||
Properties toReturn = new Properties();
|
||||
String propertiesJSONString = "";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user