-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from aferodeveloper/topic/reset-password
Fix for AferoClient.resetPasswordWithCode 400 error
- Loading branch information
Showing
17 changed files
with
560 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
afero-sdk-core/src/main/java/io/afero/sdk/client/afero/models/ResetPasswordBody.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2014-2019 Afero, Inc. All rights reserved. | ||
*/ | ||
|
||
package io.afero.sdk.client.afero.models; | ||
|
||
|
||
public class ResetPasswordBody { | ||
public String password; | ||
|
||
public ResetPasswordBody(String pw) { | ||
password = pw; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...es/afero-lab/app/src/main/java/io/afero/aferolab/resetPassword/RequestCodeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2014-2019 Afero, Inc. All rights reserved. | ||
*/ | ||
|
||
package io.afero.aferolab.resetPassword; | ||
|
||
import io.afero.aferolab.BuildConfig; | ||
import io.afero.sdk.client.afero.AferoClient; | ||
import rx.Observer; | ||
import rx.android.schedulers.AndroidSchedulers; | ||
|
||
class RequestCodeController { | ||
|
||
private RequestCodeView view; | ||
private AferoClient aferoClient; | ||
|
||
RequestCodeController(RequestCodeView requestCodeView, AferoClient aferoClient) { | ||
this.view = requestCodeView; | ||
this.aferoClient = aferoClient; | ||
} | ||
|
||
public void start() { | ||
|
||
} | ||
|
||
public void stop() { | ||
|
||
} | ||
|
||
void onClickRequestCode(String email) { | ||
view.showProgress(); | ||
aferoClient.sendPasswordRecoveryEmail(email, BuildConfig.APPLICATION_ID, "ANDROID") | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribe(new Observer<Void>() { | ||
@Override | ||
public void onCompleted() { | ||
view.hideProgress(); | ||
gotoPasswordResetView(); | ||
} | ||
|
||
@Override | ||
public void onError(Throwable e) { | ||
view.hideProgress(); | ||
view.showError(e, aferoClient.getStatusCode(e)); | ||
} | ||
|
||
@Override | ||
public void onNext(Void v) { | ||
|
||
} | ||
}); | ||
} | ||
|
||
void onClickAlreadyHaveCode() { | ||
gotoPasswordResetView(); | ||
} | ||
|
||
private void gotoPasswordResetView() { | ||
ResetPasswordView.create(view.getRootView()).start(aferoClient); | ||
view.stop(); | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
samples/afero-lab/app/src/main/java/io/afero/aferolab/resetPassword/RequestCodeView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright (c) 2014-2019 Afero, Inc. All rights reserved. | ||
*/ | ||
|
||
package io.afero.aferolab.resetPassword; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.AttrRes; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
|
||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
import butterknife.OnClick; | ||
import io.afero.aferolab.R; | ||
import io.afero.aferolab.widget.AferoEditText; | ||
import io.afero.aferolab.widget.ProgressSpinnerView; | ||
import io.afero.aferolab.widget.ScreenView; | ||
import io.afero.sdk.client.afero.AferoClient; | ||
|
||
public class RequestCodeView extends ScreenView { | ||
|
||
@BindView(R.id.edit_text_email) | ||
AferoEditText emailEditText; | ||
|
||
@BindView(R.id.progress_request_code) | ||
ProgressSpinnerView progressView; | ||
|
||
private RequestCodeController mController; | ||
|
||
|
||
public RequestCodeView(@NonNull Context context) { | ||
super(context); | ||
} | ||
|
||
public RequestCodeView(@NonNull Context context, @Nullable AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public RequestCodeView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
} | ||
|
||
public static RequestCodeView create(@NonNull View contextView) { | ||
return inflateView(R.layout.view_request_code, contextView); | ||
} | ||
|
||
@Override | ||
public void onFinishInflate() { | ||
super.onFinishInflate(); | ||
ButterKnife.bind(this); | ||
} | ||
|
||
public RequestCodeView start(AferoClient aferoClient) { | ||
pushOnBackStack(); | ||
|
||
mController = new RequestCodeController(this, aferoClient); | ||
mController.start(); | ||
|
||
emailEditText.showKeyboard(); | ||
|
||
return this; | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
mController.stop(); | ||
|
||
super.stop(); | ||
} | ||
|
||
@Override | ||
public boolean onBackPressed() { | ||
return false; | ||
} | ||
|
||
@OnClick(R.id.button_request_code) | ||
void onClickRequestCode() { | ||
emailEditText.hideKeyboard(); | ||
mController.onClickRequestCode(emailEditText.getText().toString()); | ||
} | ||
|
||
@OnClick(R.id.button_already_have_code) | ||
void onClickAlreadyHaveCode() { | ||
emailEditText.hideKeyboard(); | ||
mController.onClickAlreadyHaveCode(); | ||
} | ||
|
||
void showProgress() { | ||
progressView.show(); | ||
} | ||
|
||
void hideProgress() { | ||
progressView.hide(); | ||
} | ||
} |
Oops, something went wrong.