use of org.matrix.androidsdk.rest.model.ForgetPasswordParams in project matrix-android-sdk by matrix-org.
the class ProfileRestClient method forgetPassword.
/**
* Reset the password server side.
* @param email the email to send the password reset.
* @param callback the callback
*/
public void forgetPassword(final String email, final ApiCallback<ThreePid> callback) {
final String description = "forget password";
if (!TextUtils.isEmpty(email)) {
final ThreePid pid = new ThreePid(email, ThreePid.MEDIUM_EMAIL);
final ForgetPasswordParams forgetPasswordParams = new ForgetPasswordParams();
forgetPasswordParams.email = email;
forgetPasswordParams.client_secret = pid.clientSecret;
forgetPasswordParams.send_attempt = 1;
forgetPasswordParams.id_server = mHsConfig.getIdentityServerUri().getHost();
try {
mApi.forgetPassword(forgetPasswordParams, new RestAdapterCallback<ForgetPasswordResponse>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
forgetPassword(email, callback);
}
}) {
@Override
public void success(ForgetPasswordResponse forgetPasswordResponse, Response response) {
onEventSent();
pid.sid = forgetPasswordResponse.sid;
callback.onSuccess(pid);
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
}
Aggregations