member signin redirect
This commit is contained in:
parent
efce4ccbe9
commit
3cd9585259
|
@ -7,12 +7,12 @@ import {
|
||||||
import State from '../redux/state/SignIn';
|
import State from '../redux/state/SignIn';
|
||||||
|
|
||||||
import * as signinActions from '../redux/action/signIn';
|
import * as signinActions from '../redux/action/signIn';
|
||||||
|
import { push as routerPush } from 'react-router-redux';
|
||||||
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
|
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
|
||||||
|
|
||||||
export function mapStateToProps(state: any, ownProps?: any): SignInStateProps {
|
export function mapStateToProps(state: any, ownProps?: any): SignInStateProps {
|
||||||
return {
|
return {
|
||||||
|
isAuthenticated: state.isAuthenticated,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@ export function mapDispatchToProps(dispatch: Dispatch<any>, ownProps?: any): Sig
|
||||||
// dispatch(signinActions.request(signinId, signinPw));
|
// dispatch(signinActions.request(signinId, signinPw));
|
||||||
dispatch(asyncRequestActions.request('MemberService', 'signin', signinActions.REQUEST, signinId, signinPw));
|
dispatch(asyncRequestActions.request('MemberService', 'signin', signinActions.REQUEST, signinId, signinPw));
|
||||||
},
|
},
|
||||||
|
onRedirectHome: () => {
|
||||||
|
dispatch(routerPush('/'));
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,14 @@ const options = [
|
||||||
{ key: 'unitedstates', value: '1', text: 'United States(1)' },
|
{ key: 'unitedstates', value: '1', text: 'United States(1)' },
|
||||||
];
|
];
|
||||||
export interface StateProps {
|
export interface StateProps {
|
||||||
|
isAuthenticated?:boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DispatchProps {
|
export interface DispatchProps {
|
||||||
onSignIn?(signinId: string, signinPw: string ): void;
|
onSignIn?(signinId: string, signinPw: string ): void;
|
||||||
onSignUp?(): void;
|
onSignUp?(): void;
|
||||||
onResetPassword?():void;
|
onResetPassword?():void;
|
||||||
|
onRedirectHome():void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Props = StateProps & DispatchProps;
|
export type Props = StateProps & DispatchProps;
|
||||||
|
@ -46,8 +48,7 @@ export class SignIn extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
return (
|
let signinElement = <Form>
|
||||||
<Form>
|
|
||||||
<Form.Input fluid placeholder='Email' defaultValue={this.state.email} onChange={
|
<Form.Input fluid placeholder='Email' defaultValue={this.state.email} onChange={
|
||||||
(event: React.SyntheticEvent<HTMLInputElement>, data: InputOnChangeData) => {
|
(event: React.SyntheticEvent<HTMLInputElement>, data: InputOnChangeData) => {
|
||||||
this.setState({ email: data.value });
|
this.setState({ email: data.value });
|
||||||
|
@ -92,8 +93,13 @@ export class SignIn extends React.Component<Props, State> {
|
||||||
<Button primary onClick={this.PopupClose}> Ok </Button>
|
<Button primary onClick={this.PopupClose}> Ok </Button>
|
||||||
</Modal.Actions>
|
</Modal.Actions>
|
||||||
</Modal>
|
</Modal>
|
||||||
</Form>
|
</Form>;
|
||||||
);
|
|
||||||
|
if( this.props.isAuthenticated ) {
|
||||||
|
this.props.onRedirectHome();
|
||||||
|
} else {
|
||||||
|
return signinElement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private forgotPopupOpen = () => this.setState({ forgotPopup: true });
|
private forgotPopupOpen = () => this.setState({ forgotPopup: true });
|
||||||
|
|
|
@ -7,8 +7,10 @@ import SigninState, { defaultState as signinDefaultState } from '../state/SignIn
|
||||||
|
|
||||||
const reducer: ReducersMapObject = {
|
const reducer: ReducersMapObject = {
|
||||||
[SigninActionTypes.REQUEST_SUCCESS]: (state: SigninState = signinDefaultState, action: Action<Member>): SigninState => {
|
[SigninActionTypes.REQUEST_SUCCESS]: (state: SigninState = signinDefaultState, action: Action<Member>): SigninState => {
|
||||||
|
return {
|
||||||
return state;
|
...state,
|
||||||
|
isAuthenticated: true,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
[SigninActionTypes.REQUEST_FAILURE]: (state: SigninState = signinDefaultState, action: Action<Error>): SigninState => {
|
[SigninActionTypes.REQUEST_FAILURE]: (state: SigninState = signinDefaultState, action: Action<Error>): SigninState => {
|
||||||
return state;
|
return state;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user