Skip to content

Commit fef33d0

Browse files
authored
Merge pull request #2 from anotherdev/pk/send-password-reset-email
Send Password Reset Email
2 parents f9e2941 + 31ed668 commit fef33d0

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed

firebase-auth-rest/core/src/main/java/com/anotherdev/firebase/auth/FirebaseAuth.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import androidx.annotation.Nullable;
55

66
import com.anotherdev.firebase.auth.provider.IdpAuthCredential;
7+
import com.anotherdev.firebase.auth.rest.api.model.SendPasswordResetEmailRequest;
8+
import com.anotherdev.firebase.auth.rest.api.model.SendPasswordResetEmailResponse;
79
import com.google.firebase.FirebaseApp;
810

911
import io.reactivex.rxjava3.annotations.CheckReturnValue;
@@ -53,5 +55,9 @@ public interface FirebaseAuth {
5355
@CheckReturnValue
5456
Single<SignInResponse> linkWithCredential(@NonNull FirebaseUser user, @NonNull IdpAuthCredential credential);
5557

58+
@NonNull
59+
@CheckReturnValue
60+
Single<SendPasswordResetEmailResponse> sendPasswordResetEmail(SendPasswordResetEmailRequest request);
61+
5662
void signOut();
5763
}

firebase-auth-rest/core/src/main/java/com/anotherdev/firebase/auth/rest/RestAuthProvider.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import com.anotherdev.firebase.auth.rest.api.RestAuthApi;
1515
import com.anotherdev.firebase.auth.rest.api.model.ExchangeTokenRequest;
1616
import com.anotherdev.firebase.auth.rest.api.model.ImmutableSignInWithIdpRequest;
17+
import com.anotherdev.firebase.auth.rest.api.model.SendPasswordResetEmailRequest;
18+
import com.anotherdev.firebase.auth.rest.api.model.SendPasswordResetEmailResponse;
1719
import com.anotherdev.firebase.auth.rest.api.model.SignInAnonymouslyRequest;
1820
import com.anotherdev.firebase.auth.rest.api.model.SignInWithCustomTokenRequest;
1921
import com.anotherdev.firebase.auth.rest.api.model.SignInWithEmailPasswordRequest;
@@ -155,6 +157,12 @@ private Single<SignInResponse> performSignInWithCredential(ImmutableSignInWithId
155157
.map(this::saveCurrentUser);
156158
}
157159

160+
@NonNull
161+
@Override
162+
public Single<SendPasswordResetEmailResponse> sendPasswordResetEmail(SendPasswordResetEmailRequest request) {
163+
return RestAuthApi.auth().sendPasswordResetEmail(request);
164+
}
165+
158166
@Override
159167
public void signOut() {
160168
userStore.delete();

firebase-auth-rest/core/src/main/java/com/anotherdev/firebase/auth/rest/api/IdentityToolkitApi.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.anotherdev.firebase.auth.UserProfileChangeRequest;
55
import com.anotherdev.firebase.auth.UserProfileChangeResponse;
66
import com.anotherdev.firebase.auth.rest.api.model.IdTokenRequest;
7+
import com.anotherdev.firebase.auth.rest.api.model.SendPasswordResetEmailRequest;
8+
import com.anotherdev.firebase.auth.rest.api.model.SendPasswordResetEmailResponse;
79
import com.anotherdev.firebase.auth.rest.api.model.SignInRequest;
810
import com.anotherdev.firebase.auth.rest.api.model.SignInWithCustomTokenRequest;
911
import com.anotherdev.firebase.auth.rest.api.model.SignInWithEmailPasswordRequest;
@@ -36,6 +38,9 @@ public interface IdentityToolkitApi {
3638
@POST("v1/accounts:signInWithCustomToken")
3739
Single<SignInResponse> signInWithCustomToken(@Body SignInWithCustomTokenRequest request);
3840

41+
@POST("v1/accounts:sendOobCode")
42+
Single<SendPasswordResetEmailResponse> sendPasswordResetEmail(@Body SendPasswordResetEmailRequest request);
43+
3944
@POST("v1/accounts:lookup")
4045
Single<JsonObject> getAccounts(@Body IdTokenRequest request);
4146

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.anotherdev.firebase.auth.rest.api.model;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
5+
import org.immutables.gson.Gson;
6+
import org.immutables.value.Value;
7+
8+
@Value.Immutable
9+
@Value.Style(strictBuilder = true)
10+
@Gson.TypeAdapters
11+
public interface SendPasswordResetEmailRequest {
12+
13+
@SerializedName("email")
14+
String getEmail();
15+
16+
@Value.Default
17+
@SerializedName("requestType")
18+
default String getRequestType() {
19+
return "PASSWORD_RESET";
20+
}
21+
22+
23+
static ImmutableSendPasswordResetEmailRequest.Builder builder() {
24+
return ImmutableSendPasswordResetEmailRequest.builder();
25+
}
26+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.anotherdev.firebase.auth.rest.api.model;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
5+
import org.immutables.gson.Gson;
6+
import org.immutables.value.Value;
7+
8+
@Value.Immutable
9+
@Value.Style(strictBuilder = true)
10+
@Gson.TypeAdapters
11+
public interface SendPasswordResetEmailResponse {
12+
13+
@SerializedName("email")
14+
String getEmail();
15+
16+
17+
static ImmutableSendPasswordResetEmailResponse.Builder builder() {
18+
return ImmutableSendPasswordResetEmailResponse.builder();
19+
}
20+
}

0 commit comments

Comments
 (0)