Add OAuth Login facebook,google,github
This commit is contained in:
@@ -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 _____________ */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user