Skip to content

Commit 72d3d38

Browse files
committed
added currentUser.reload() method - android only, needs ios
1 parent d20ecda commit 72d3d38

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

android/src/main/java/io/fullstack/firestack/auth/FirestackAuth.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,32 @@ public void signOut(final Callback callback) {
475475
callback.invoke(null, resp);
476476
}
477477

478+
@ReactMethod
479+
public void reloadUser(final Callback callback) {
480+
FirebaseUser user = mAuth.getCurrentUser();
481+
482+
if (user == null) {
483+
callbackNoUser(callback, false);
484+
} else {
485+
user.reload()
486+
.addOnCompleteListener(new OnCompleteListener<Void>() {
487+
@Override
488+
public void onComplete(@NonNull Task<Void> task) {
489+
if (task.isSuccessful()) {
490+
Log.d(TAG, "user reloaded");
491+
userCallback(mAuth.getCurrentUser(), callback);
492+
} else {
493+
userErrorCallback(task, callback);
494+
}
495+
}
496+
});
497+
}
498+
}
499+
478500
@ReactMethod
479501
public void getCurrentUser(final Callback callback) {
480502
FirebaseUser user = mAuth.getCurrentUser();
503+
481504
if (user == null) {
482505
callbackNoUser(callback, false);
483506
} else {

lib/modules/auth/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,14 @@ export default class Auth extends Base {
186186
return promisify('deleteUser', FirestackAuth, 'auth/')();
187187
}
188188

189+
/**
190+
* Delete the current user
191+
* @return {Promise}
192+
*/
193+
reloadUser(): Promise<Object> {
194+
return promisify('reloadUser', FirestackAuth, 'auth/')();
195+
}
196+
189197
/**
190198
* get the token of current user
191199
* @return {Promise}

lib/modules/user.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ export default class User {
9292
return this._auth.deleteUser(...args);
9393
}
9494

95+
reload(...args) {
96+
return this._auth.reload(...args);
97+
}
98+
9599
// TODO valueOrNul token - optional promise
96100
getToken(...args) {
97101
return this._auth.getToken(...args);

0 commit comments

Comments
 (0)