1
- import promisify from '../utils/promisify' ;
2
- import { Base } from './base' ;
3
-
4
-
1
+ // TODO refreshToken property
2
+ // TODO reload() method
5
3
export default class User {
6
4
constructor ( authClass , authObj ) {
7
5
this . _auth = authClass ;
@@ -33,7 +31,7 @@ export default class User {
33
31
* @returns {* }
34
32
* @private
35
33
*/
36
- _getOrNull ( prop ) {
34
+ _valueOrNull ( prop ) {
37
35
if ( ! this . _user ) return null ;
38
36
if ( ! Object . hasOwnProperty . call ( this . _user , prop ) ) return null ;
39
37
return this . _user [ prop ] ;
@@ -44,47 +42,48 @@ export default class User {
44
42
*/
45
43
46
44
get displayName ( ) {
47
- return this . _getOrNull ( 'displayName' ) ;
45
+ return this . _valueOrNull ( 'displayName' ) ;
48
46
}
49
47
50
48
get email ( ) {
51
- return this . _getOrNull ( 'email' ) ;
49
+ return this . _valueOrNull ( 'email' ) ;
52
50
}
53
51
54
52
get emailVerified ( ) {
55
- return this . _getOrNull ( 'emailVerified' ) ;
53
+ return this . _valueOrNull ( 'emailVerified' ) ;
56
54
}
57
55
58
56
get isAnonymous ( ) {
59
- return ! this . _getOrNull ( 'email' ) && this . _getOrNull ( 'providerId' ) === 'firebase' ;
57
+ return ! this . _valueOrNull ( 'email' ) && this . _valueOrNull ( 'providerId' ) === 'firebase' ;
60
58
}
61
59
62
60
get photoURL ( ) {
63
- return this . _getOrNull ( 'photoURL' ) ;
61
+ return this . _valueOrNull ( 'photoURL' ) ;
64
62
}
65
63
66
64
get photoUrl ( ) {
67
- return this . _getOrNull ( 'photoURL' ) ;
65
+ return this . _valueOrNull ( 'photoURL' ) ;
68
66
}
69
67
70
68
// TODO no android method yet, the SDK does have .getProviderData but returns as a List.
71
69
// get providerData() {
72
- // return this._getOrNull ('providerData');
70
+ // return this._valueOrNull ('providerData');
73
71
// }
74
72
75
73
get providerId ( ) {
76
- return this . _getOrNull ( 'providerId' ) ;
74
+ return this . _valueOrNull ( 'providerId' ) ;
77
75
}
78
76
79
- // TODO no
77
+ // TODO no android method?
80
78
// get refreshToken() {
81
- // return this._getOrNull ('refreshToken');
79
+ // return this._valueOrNull ('refreshToken');
82
80
// }
83
81
84
82
get uid ( ) {
85
- return this . _getOrNull ( 'uid' ) ;
83
+ return this . _valueOrNull ( 'uid' ) ;
86
84
}
87
85
86
+ // noinspection ReservedWordAsName
88
87
/**
89
88
* METHODS
90
89
*/
@@ -97,8 +96,13 @@ export default class User {
97
96
return this . _auth . getToken ( ...args ) ;
98
97
}
99
98
99
+ get reauthenticate ( ) {
100
+ return this . _auth . reauthenticateUser ;
101
+ }
102
+
103
+ // TODO match errors to auth/something errors from firebase web api
100
104
get updateEmail ( ) {
101
- if ( this . isAnonymous ) return ( ) => Promise . reject ( new Error ( 'Can not update email on an annonymous user.' ) ) ;
105
+ if ( this . isAnonymous ) return ( ) => Promise . reject ( new Error ( 'Can not update email on an anonymous user.' ) ) ;
102
106
return this . _auth . updateEmail ;
103
107
}
104
108
@@ -107,12 +111,12 @@ export default class User {
107
111
}
108
112
109
113
get updatePassword ( ) {
110
- if ( this . isAnonymous ) return ( ) => Promise . reject ( new Error ( 'Can not update password on an annonymous user.' ) ) ;
114
+ if ( this . isAnonymous ) return ( ) => Promise . reject ( new Error ( 'Can not update password on an anonymous user.' ) ) ;
111
115
return this . _auth . updatePassword ;
112
116
}
113
117
114
118
get sendEmailVerification ( ) {
115
- if ( this . isAnonymous ) return ( ) => Promise . reject ( new Error ( 'Can not verify email on an annonymous user.' ) ) ;
119
+ if ( this . isAnonymous ) return ( ) => Promise . reject ( new Error ( 'Can not verify email on an anonymous user.' ) ) ;
116
120
return this . _auth . sendEmailVerification ;
117
121
}
118
122
}
0 commit comments