Add OAuth Login facebook,google,github

This commit is contained in:
Qolzam
2017-11-18 19:04:31 +07:00
parent f64b7bb24d
commit 92379b615c
23 changed files with 513 additions and 264 deletions

View File

@@ -6,6 +6,7 @@ import { push } from 'react-router-redux'
// -Import domain
import { User } from 'core/domain/users'
import { SocialError } from 'core/domain/common'
import { OAuthType, LoginUser } from 'core/domain/authorize'
import { UserRegisterModel } from 'models/users/userRegisterModel'
@@ -150,6 +151,27 @@ export const dbSendEmailVerfication = () => {
}
}
/**
* Login user with OAuth
*/
export const dbLoginWithOAuth = (type: OAuthType) => {
return (dispatch: any, getState: any) => {
dispatch(globalActions.showNotificationRequest())
return authorizeService.loginWithOAuth(type).then((result: LoginUser) => {
// Send email verification successful.
dispatch(globalActions.showNotificationSuccess())
dispatch(login(result.uid, true))
dispatch(push('/'))
})
.catch((error: SocialError) => {
// An error happened.
dispatch(globalActions.showErrorMessage(error.code))
})
}
}
/* _____________ CRUD State _____________ */
/**