mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
Merge branch 'master' of https://github.com/invertase/react-native-firebase into v3
# Conflicts: # ios/RNFirebase/admob/RNFirebaseAdMob.m # ios/RNFirebase/database/RNFirebaseDatabase.h # ios/RNFirebase/database/RNFirebaseDatabaseReference.m # lib/modules/admob/index.js # tests/ios/Podfile.lock
This commit is contained in:
25
lib/modules/auth/ConfirmationResult.js
Normal file
25
lib/modules/auth/ConfirmationResult.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @url https://firebase.google.com/docs/reference/js/firebase.User
|
||||
*/
|
||||
export default class ConfirmationResult {
|
||||
_auth: Object;
|
||||
_verificationId: string;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param verificationId The phone number authentication operation's verification ID.
|
||||
*/
|
||||
constructor(auth: Object, verificationId: string) {
|
||||
this._auth = auth;
|
||||
this._verificationId = verificationId;
|
||||
}
|
||||
|
||||
confirm(verificationCode: string): Promise<Object> {
|
||||
// verificationId is stored server side in case the app is shut when opening the SMS app
|
||||
return this._auth._native.confirmVerificationCode(verificationCode);
|
||||
}
|
||||
|
||||
get verificationId(): String | null {
|
||||
return _verificationId;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
// @flow
|
||||
import User from './user';
|
||||
import ModuleBase from './../../utils/ModuleBase';
|
||||
import ConfirmationResult from './ConfirmationResult';
|
||||
|
||||
// providers
|
||||
import EmailAuthProvider from './providers/Email';
|
||||
import PhoneAuthProvider from './providers/Phone';
|
||||
import GoogleAuthProvider from './providers/Google';
|
||||
import FacebookAuthProvider from './providers/Facebook';
|
||||
import TwitterAuthProvider from './providers/Twitter';
|
||||
import GithubAuthProvider from './providers/Github';
|
||||
import TwitterAuthProvider from './providers/Twitter';
|
||||
import FacebookAuthProvider from './providers/Facebook';
|
||||
|
||||
export default class Auth extends ModuleBase {
|
||||
_user: User | null;
|
||||
@@ -139,6 +141,17 @@ export default class Auth extends ModuleBase {
|
||||
return this._interceptUserValue(this._native.signInWithCredential(credential.provider, credential.token, credential.secret));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @return {Promise.<TResult>}
|
||||
*/
|
||||
signInWithPhoneNumber(phoneNumber: string): Promise<Object> {
|
||||
return this._native.signInWithPhoneNumber(phoneNumber).then((result) => {
|
||||
return new ConfirmationResult(this, result.verificationId);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Send reset password instructions via email
|
||||
* @param {string} email The email to send password reset instructions
|
||||
@@ -211,9 +224,10 @@ export default class Auth extends ModuleBase {
|
||||
}
|
||||
|
||||
export const statics = {
|
||||
GoogleAuthProvider,
|
||||
EmailAuthProvider,
|
||||
FacebookAuthProvider,
|
||||
TwitterAuthProvider,
|
||||
PhoneAuthProvider,
|
||||
GoogleAuthProvider,
|
||||
GithubAuthProvider,
|
||||
TwitterAuthProvider,
|
||||
FacebookAuthProvider,
|
||||
};
|
||||
|
||||
10
lib/modules/auth/providers/Phone.js
Normal file
10
lib/modules/auth/providers/Phone.js
Normal file
@@ -0,0 +1,10 @@
|
||||
export default {
|
||||
credential(verificationId, code) {
|
||||
return {
|
||||
token: verificationId,
|
||||
secret: code,
|
||||
provider: 'phone',
|
||||
providerId: 'phone',
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user