react-native-firebase/lib/modules/auth/ConfirmationResult.js

38 lines
844 B
JavaScript
Raw Normal View History

2017-08-25 11:16:23 +00:00
/**
2017-11-17 14:22:46 +00:00
* @flow
* ConfirmationResult representation wrapper
2017-08-25 11:16:23 +00:00
*/
import { getNativeModule } from '../../utils/native';
2017-11-17 14:22:46 +00:00
import type Auth from './';
import type User from './User';
2017-08-25 11:16:23 +00:00
export default class ConfirmationResult {
2017-11-17 14:22:46 +00:00
_auth: Auth;
2017-08-25 11:16:23 +00:00
_verificationId: string;
/**
*
* @param auth
* @param verificationId The phone number authentication operation's verification ID.
*/
2017-11-17 14:22:46 +00:00
constructor(auth: Auth, verificationId: string) {
2017-08-25 11:16:23 +00:00
this._auth = auth;
this._verificationId = verificationId;
}
/**
*
* @param verificationCode
* @return {*}
*/
2018-01-24 09:46:39 +00:00
confirm(verificationCode: string): Promise<User> {
return getNativeModule(this._auth)
._confirmVerificationCode(verificationCode)
.then(user => this._auth._setUser(user));
2017-08-25 11:16:23 +00:00
}
2017-11-17 14:22:46 +00:00
get verificationId(): string | null {
return this._verificationId;
2017-08-25 11:16:23 +00:00
}
}