1
- import * as firebase from "../../firebase" ;
2
- import { FirebaseEmailLinkActionCodeSettings , LoginType , User , Unsubscribe } from "../../firebase" ;
1
+ import { firebase } from "../../firebase" ;
3
2
4
3
export namespace auth {
5
4
export class Auth {
6
5
private authStateChangedHandler ;
7
6
private authStateOnErrorHandler ;
8
- public currentUser : User ;
7
+ public currentUser : firebase . User ;
9
8
public languageCode : string | null ;
10
9
11
10
private loginHelper ( options : firebase . LoginOptions ) {
12
11
return new Promise ( ( resolve , reject ) => {
13
12
firebase . login ( options )
14
- . then ( ( user : User ) => {
13
+ . then ( ( user : firebase . User ) => {
15
14
this . currentUser = user ;
16
15
this . authStateChangedHandler && this . authStateChangedHandler ( user ) ;
17
16
resolve ( {
@@ -45,7 +44,7 @@ export namespace auth {
45
44
46
45
// Completed will never be called, but it is here to closely follow the web api interface.
47
46
// When called, the callback handler will be passed in the currentUser or undefined if not signed in
48
- public onAuthStateChanged ( handler : ( user : User ) => void , error ?: ( err ) => any , completed ?: Unsubscribe ) : Unsubscribe {
47
+ public onAuthStateChanged ( handler : ( user : firebase . User ) => void , error ?: ( err ) => any , completed ?: firebase . Unsubscribe ) : firebase . Unsubscribe {
49
48
this . authStateChangedHandler = handler ;
50
49
if ( error ) this . authStateOnErrorHandler = error ;
51
50
console . log ( ">> added onAuthStateChanged handler" ) ;
@@ -92,7 +91,7 @@ export namespace auth {
92
91
93
92
public signInWithEmailAndPassword ( email : string , password : string ) : Promise < any > {
94
93
const emailOption : firebase . LoginOptions = {
95
- type : LoginType . PASSWORD ,
94
+ type : firebase . LoginType . PASSWORD ,
96
95
passwordOptions : {
97
96
email : email ,
98
97
password : password
@@ -103,7 +102,7 @@ export namespace auth {
103
102
104
103
public signInWithCustomToken ( token : string ) : Promise < any > {
105
104
const customTokenOption : firebase . LoginOptions = {
106
- type : LoginType . CUSTOM ,
105
+ type : firebase . LoginType . CUSTOM ,
107
106
customOptions : {
108
107
token : token
109
108
}
@@ -113,14 +112,14 @@ export namespace auth {
113
112
114
113
public signInAnonymously ( ) : Promise < any > {
115
114
const anonymousOption : firebase . LoginOptions = {
116
- type : LoginType . ANONYMOUS
115
+ type : firebase . LoginType . ANONYMOUS
117
116
} ;
118
117
return this . loginHelper ( anonymousOption ) ;
119
118
}
120
119
121
- public sendSignInLinkToEmail ( email : string , actionCodeSettings : FirebaseEmailLinkActionCodeSettings ) : Promise < any > {
120
+ public sendSignInLinkToEmail ( email : string , actionCodeSettings : firebase . FirebaseEmailLinkActionCodeSettings ) : Promise < any > {
122
121
const sendSignInLinklOption : firebase . LoginOptions = {
123
- type : LoginType . EMAIL_LINK ,
122
+ type : firebase . LoginType . EMAIL_LINK ,
124
123
emailLinkOptions : {
125
124
email : email ,
126
125
url : actionCodeSettings . url ,
@@ -140,12 +139,12 @@ export namespace auth {
140
139
return this . loginHelper ( signInWithEmailOption ) ;
141
140
}
142
141
143
- public createUserWithEmailAndPassword ( email : string , password : string ) : Promise < User > {
142
+ public createUserWithEmailAndPassword ( email : string , password : string ) : Promise < firebase . User > {
144
143
return new Promise ( ( resolve , reject ) => {
145
144
firebase . createUser ( {
146
145
email : email ,
147
146
password : password
148
- } ) . then ( ( user : User ) => {
147
+ } ) . then ( ( user : firebase . User ) => {
149
148
this . currentUser = user ;
150
149
resolve ( user ) ;
151
150
} ) . catch ( err => reject ( err ) ) ;
0 commit comments