mirror of
https://github.com/wassname/talk.git
synced 2026-07-18 12:40:13 +08:00
Ádding dispatcher for FacebookCallback
This commit is contained in:
@@ -30,8 +30,8 @@ export const fetchSignIn = () => dispatch => {
|
||||
// Sign In - Facebook
|
||||
|
||||
const signInFacebookRequest = () => ({type: actions.FETCH_SIGNIN_FACEBOOK_REQUEST});
|
||||
//const signInFacebookSuccess = () => ({type: actions.FETCH_SIGNIN_FACEBOOK_SUCCESS});
|
||||
//const signInFacebookFailure = () => ({type: actions.FETCH_SIGNIN_FACEBOOK_FAILURE});
|
||||
const signInFacebookSuccess = () => ({type: actions.FETCH_SIGNIN_FACEBOOK_SUCCESS});
|
||||
const signInFacebookFailure = () => ({type: actions.FETCH_SIGNIN_FACEBOOK_FAILURE});
|
||||
|
||||
export const fetchSignInFacebook = () => dispatch => {
|
||||
dispatch(signInFacebookRequest());
|
||||
@@ -42,6 +42,19 @@ export const fetchSignInFacebook = () => dispatch => {
|
||||
);
|
||||
};
|
||||
|
||||
export const facebookCallback = (err, data) => dispatch => {
|
||||
if (err) {
|
||||
signInFacebookFailure(err);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
dispatch(signInFacebookSuccess(JSON.parse(data)));
|
||||
} catch (err) {
|
||||
dispatch(signInFacebookFailure(err));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// Sign Up Actions
|
||||
|
||||
const signUpRequest = () => ({type: actions.FETCH_SIGNUP_REQUEST});
|
||||
|
||||
@@ -14,7 +14,8 @@ import {
|
||||
showSignInDialog,
|
||||
hideSignInDialog,
|
||||
fetchSignInFacebook,
|
||||
fetchForgotPassword
|
||||
fetchForgotPassword,
|
||||
facebookCallback
|
||||
} from '../../coral-framework/actions/auth';
|
||||
|
||||
class SignInContainer extends Component {
|
||||
@@ -40,6 +41,10 @@ class SignInContainer extends Component {
|
||||
this.validation = this.validation.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
window.authCallback = this.props.facebookCallback;
|
||||
}
|
||||
|
||||
cleanState () {
|
||||
this.setState(this.initialState);
|
||||
}
|
||||
@@ -139,6 +144,7 @@ class SignInContainer extends Component {
|
||||
const mapStateToProps = ({auth}) => ({auth});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
facebookCallback: (err, data) => dispatch(facebookCallback(err, data)),
|
||||
fetchSignUp: (formData) => dispatch(fetchSignUp(formData)),
|
||||
fetchSignIn: (formData) => dispatch(fetchSignIn(formData)),
|
||||
fetchSignInFacebook: () => dispatch(fetchSignInFacebook()),
|
||||
|
||||
Reference in New Issue
Block a user