Search in sources :

Example 1 with ThreePid

use of org.matrix.androidsdk.rest.model.pid.ThreePid 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));
        }
    }
}
Also used : TokenRefreshResponse(org.matrix.androidsdk.rest.model.login.TokenRefreshResponse) RequestPhoneNumberValidationResponse(org.matrix.androidsdk.rest.model.RequestPhoneNumberValidationResponse) AccountThreePidsResponse(org.matrix.androidsdk.rest.model.pid.AccountThreePidsResponse) ForgetPasswordResponse(org.matrix.androidsdk.rest.model.ForgetPasswordResponse) Response(retrofit.client.Response) RequestEmailValidationResponse(org.matrix.androidsdk.rest.model.RequestEmailValidationResponse) ForgetPasswordResponse(org.matrix.androidsdk.rest.model.ForgetPasswordResponse) ForgetPasswordParams(org.matrix.androidsdk.rest.model.ForgetPasswordParams) ThreePid(org.matrix.androidsdk.rest.model.pid.ThreePid)

Aggregations

ForgetPasswordParams (org.matrix.androidsdk.rest.model.ForgetPasswordParams)1 ForgetPasswordResponse (org.matrix.androidsdk.rest.model.ForgetPasswordResponse)1 RequestEmailValidationResponse (org.matrix.androidsdk.rest.model.RequestEmailValidationResponse)1 RequestPhoneNumberValidationResponse (org.matrix.androidsdk.rest.model.RequestPhoneNumberValidationResponse)1 TokenRefreshResponse (org.matrix.androidsdk.rest.model.login.TokenRefreshResponse)1 AccountThreePidsResponse (org.matrix.androidsdk.rest.model.pid.AccountThreePidsResponse)1 ThreePid (org.matrix.androidsdk.rest.model.pid.ThreePid)1 Response (retrofit.client.Response)1