[ios][android][auth] getToken now correctly accepts forceRefresh argument. Fixes #21.

This commit is contained in:
Salakar 2017-03-30 10:55:16 +01:00
parent 89a0354e4b
commit 48e57d2065
3 changed files with 6 additions and 6 deletions

View File

@ -606,12 +606,12 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
* @param promise
*/
@ReactMethod
public void getToken(final Promise promise) {
public void getToken(final Boolean forceRefresh, final Promise promise) {
FirebaseUser user = mAuth.getCurrentUser();
Log.d(TAG, "getToken");
if (user != null) {
user.getToken(true)
user.getToken(forceRefresh)
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
@Override
public void onComplete(@NonNull Task<GetTokenResult> task) {

View File

@ -278,11 +278,11 @@ RCT_EXPORT_METHOD(updateProfile:(NSDictionary *) props resolver:(RCTPromiseResol
@param RCTPromiseRejectBlock reject
@return
*/
RCT_EXPORT_METHOD(getToken:(RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject) {
RCT_EXPORT_METHOD(getToken:(BOOL)forceRefresh resolver:(RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject) {
FIRUser *user = [FIRAuth auth].currentUser;
if (user) {
[user getTokenWithCompletion:^(NSString *token, NSError *_Nullable error) {
[user getTokenForcingRefresh:(BOOL) forceRefresh completion:^(NSString *token, NSError *_Nullable error) {
if (error) {
[self promiseRejectAuthException:reject error:error];
} else {

View File

@ -140,8 +140,8 @@ export default class User {
* get the token of current user
* @return {Promise}
*/
getToken(): Promise<Object> {
return FirebaseAuth.getToken();
getToken(forceRefresh: Boolean = false): Promise<Object> {
return FirebaseAuth.getToken(forceRefresh);
}
// TODO return from native