[Feature Request] User account confirmation (#23)

This commit is contained in:
Qolzam
2017-11-16 11:44:45 +07:00
parent 55789967eb
commit f64b7bb24d
26 changed files with 571 additions and 231 deletions

View File

@@ -27,7 +27,7 @@ export class AuthorizeService implements IAuthorizeService {
firebaseAuth()
.signInWithEmailAndPassword(email, password)
.then((result) => {
resolve(new LoginUser(result.uid))
resolve(new LoginUser(result.uid, result.emailVerified))
})
.catch((error: any) => {
reject(new SocialError(error.code, error.message))
@@ -108,8 +108,18 @@ export class AuthorizeService implements IAuthorizeService {
*
* @memberof IAuthorizeService
*/
public onAuthStateChanged: (callBack: (user: User) => void) => any = (callBack) => {
firebaseAuth().onAuthStateChanged(callBack)
public onAuthStateChanged: (callBack: (isVerifide: boolean, user: User) => void) => any = (callBack) => {
firebaseAuth().onAuthStateChanged( (user: any) => {
let isVerifide = false
if (user) {
if (user.emailVerified) {
isVerifide = true
} else {
isVerifide = false
}
}
callBack(isVerifide,user)
})
}
/**
@@ -129,4 +139,23 @@ export class AuthorizeService implements IAuthorizeService {
})
})
}
public sendEmailVerification: () => Promise<void> = () => {
return new Promise<void>((resolve,reject) => {
let auth = firebaseAuth()
const user = auth.currentUser
if (user) {
user.sendEmailVerification().then(() => {
resolve()
}).catch((error: any) => {
// An error happened.
reject(new SocialError(error.code, error.message))
})
} else {
reject(new SocialError('nullException', 'User was null'));
}
})
}
}