diff --git a/client/coral-embed-stream/src/AppRouter.js b/client/coral-embed-stream/src/AppRouter.js
index e2553889c..6ee63caab 100644
--- a/client/coral-embed-stream/src/AppRouter.js
+++ b/client/coral-embed-stream/src/AppRouter.js
@@ -2,12 +2,12 @@ import React from 'react';
import {Router, Route, browserHistory} from 'react-router';
import Embed from './containers/Embed';
-import SignInContainer from 'coral-sign-in/containers/SignInContainer';
+import {LoginContainer} from 'coral-sign-in/containers/LoginContainer';
const routes = (
-
-
+
+
);
diff --git a/client/coral-sign-in/containers/LoginContainer.js b/client/coral-sign-in/containers/LoginContainer.js
new file mode 100644
index 000000000..fa20de4ed
--- /dev/null
+++ b/client/coral-sign-in/containers/LoginContainer.js
@@ -0,0 +1,6 @@
+import React from 'react';
+import Slot from 'coral-framework/components/Slot';
+
+export const LoginContainer = () => (
+
+)
\ No newline at end of file
diff --git a/client/coral-sign-in/containers/SignInContainer.js b/client/coral-sign-in/containers/SignInContainer.js
index de1d2086e..b473626db 100644
--- a/client/coral-sign-in/containers/SignInContainer.js
+++ b/client/coral-sign-in/containers/SignInContainer.js
@@ -1,220 +1,5 @@
-import React, {Component, PropTypes} from 'react';
-import {connect} from 'react-redux';
-import SignDialog from '../components/SignDialog';
-import validate from 'coral-framework/helpers/validate';
-import errorMsj from 'coral-framework/helpers/error';
-import I18n from 'coral-framework/modules/i18n/i18n';
-import translations from '../translations';
-import {pym} from 'coral-framework';
-const lang = new I18n(translations);
+import React from 'react';
-import {
- changeView,
- fetchSignUp,
- fetchSignIn,
- hideSignInDialog,
- fetchSignInFacebook,
- fetchSignUpFacebook,
- fetchForgotPassword,
- requestConfirmEmail,
- facebookCallback,
- invalidForm,
- validForm,
- checkLogin
-} from 'coral-framework/actions/auth';
-
-class SignInContainer extends Component {
- initialState = {
- formData: {
- email: '',
- username: '',
- password: '',
- confirmPassword: ''
- },
- emailToBeResent: '',
- errors: {},
- showErrors: false
- };
-
- constructor(props) {
- super(props);
- this.state = this.initialState;
- this.addError = this.addError.bind(this);
- this.handleAuth = this.handleAuth.bind(this);
- this.handleSignUp = this.handleSignUp.bind(this);
- this.handleSignIn = this.handleSignIn.bind(this);
- this.handleChange = this.handleChange.bind(this);
- this.handleChangeEmail = this.handleChangeEmail.bind(this);
- this.handleResendVerification = this.handleResendVerification.bind(this);
- }
-
- static propTypes = {
- requireEmailConfirmation: PropTypes.bool.isRequired
- };
-
- componentWillMount() {
- this.props.checkLogin();
- }
-
- componentDidMount() {
- window.addEventListener('storage', this.handleAuth);
-
- const {formData} = this.state;
- const errors = Object.keys(formData).reduce((map, prop) => {
- map[prop] = lang.t('signIn.requiredField');
- return map;
- }, {});
- this.setState({errors});
- }
-
- componentWillUnmount() {
- window.removeEventListener('storage', this.handleAuth);
- }
-
- handleAuth(e) {
-
- // Listening to FB changes
- // FB localStorage key is 'auth'
- const authCallback = this.props.facebookCallback;
-
- if (e.key === 'auth') {
- const {err, data} = JSON.parse(e.newValue);
- authCallback(err, data);
- }
- }
-
- handleChange(e) {
- const {name, value} = e.target;
- this.setState(
- (state) => ({
- ...state,
- formData: {
- ...state.formData,
- [name]: value
- }
- }),
- () => {
- this.validation(name, value);
- }
- );
- }
-
- handleChangeEmail(e) {
- const {value} = e.target;
- this.setState({emailToBeResent: value});
- }
-
- handleResendVerification(e) {
- e.preventDefault();
- this.props
- .requestConfirmEmail(
- this.state.emailToBeResent,
- pym.parentUrl || location.href
- )
- .then(() => {
- setTimeout(() => {
-
- // allow success UI to be shown for a second, and then close the modal
- this.props.handleClose();
- }, 2500);
- });
- }
-
- addError(name, error) {
- return this.setState((state) => ({
- errors: {
- ...state.errors,
- [name]: error
- }
- }));
- }
-
- validation(name, value) {
- const {addError} = this;
- const {formData} = this.state;
-
- if (!value.length) {
- addError(name, lang.t('signIn.requiredField'));
- } else if (
- name === 'confirmPassword' &&
- formData.confirmPassword !== formData.password
- ) {
- addError('confirmPassword', lang.t('signIn.passwordsDontMatch'));
- } else if (!validate[name](value)) {
- addError(name, errorMsj[name]);
- } else {
- const {[name]: prop, ...errors} = this.state.errors; // eslint-disable-line
- // Removes Error
- this.setState((state) => ({...state, errors}));
- }
- }
-
- isCompleted() {
- const {formData} = this.state;
- return !Object.keys(formData).filter((prop) => !formData[prop].length).length;
- }
-
- displayErrors(show = true) {
- this.setState({showErrors: show});
- }
-
- handleSignUp(e) {
- e.preventDefault();
- const {errors} = this.state;
- const {fetchSignUp, validForm, invalidForm} = this.props;
- this.displayErrors();
- if (this.isCompleted() && !Object.keys(errors).length) {
- fetchSignUp(this.state.formData, pym.parentUrl || location.href);
- validForm();
- } else {
- invalidForm(lang.t('signIn.checkTheForm'));
- }
- }
-
- handleSignIn(e) {
- e.preventDefault();
- this.props.fetchSignIn(this.state.formData);
- }
-
- render() {
- const {auth, requireEmailConfirmation} = this.props;
- const {emailVerificationLoading, emailVerificationSuccess} = auth;
-
- return (
-
-
-
- );
- }
-}
-
-const mapStateToProps = (state) => ({
- auth: state.auth.toJS()
-});
-
-const mapDispatchToProps = (dispatch) => ({
- checkLogin: () => dispatch(checkLogin()),
- facebookCallback: (err, data) => dispatch(facebookCallback(err, data)),
- fetchSignUp: (formData, url) => dispatch(fetchSignUp(formData, url)),
- fetchSignIn: (formData) => dispatch(fetchSignIn(formData)),
- fetchSignInFacebook: () => dispatch(fetchSignInFacebook()),
- fetchSignUpFacebook: () => dispatch(fetchSignUpFacebook()),
- fetchForgotPassword: (formData) => dispatch(fetchForgotPassword(formData)),
- requestConfirmEmail: (email, url) =>
- dispatch(requestConfirmEmail(email, url)),
- changeView: (view) => dispatch(changeView(view)),
- handleClose: () => dispatch(hideSignInDialog()),
- invalidForm: (error) => dispatch(invalidForm(error)),
- validForm: () => dispatch(validForm())
-});
-
-export default connect(mapStateToProps, mapDispatchToProps)(SignInContainer);
+export const SignInContainer = () => (
+
+)
\ No newline at end of file
diff --git a/plugins/coral-plugin-auth/client/components/SignInContainer.js b/plugins/coral-plugin-auth/client/components/SignInContainer.js
new file mode 100644
index 000000000..06a747556
--- /dev/null
+++ b/plugins/coral-plugin-auth/client/components/SignInContainer.js
@@ -0,0 +1,210 @@
+import React, {Component, PropTypes} from 'react';
+import {connect} from 'react-redux';
+import validate from 'coral-framework/helpers/validate';
+import errorMsj from 'coral-framework/helpers/error';
+import I18n from 'coral-framework/modules/i18n/i18n';
+import translations from '../translations';
+import {pym} from 'coral-framework';
+const lang = new I18n(translations);
+
+import {
+ changeView,
+ fetchSignUp,
+ fetchSignIn,
+ hideSignInDialog,
+ fetchSignInFacebook,
+ fetchSignUpFacebook,
+ fetchForgotPassword,
+ requestConfirmEmail,
+ facebookCallback,
+ invalidForm,
+ validForm,
+ checkLogin
+} from 'coral-framework/actions/auth';
+
+class SignInContainer extends Component {
+ initialState = {
+ formData: {
+ email: '',
+ username: '',
+ password: '',
+ confirmPassword: ''
+ },
+ emailToBeResent: '',
+ errors: {},
+ showErrors: false
+ };
+
+ constructor(props) {
+ super(props);
+ this.state = this.initialState;
+ this.addError = this.addError.bind(this);
+ this.handleAuth = this.handleAuth.bind(this);
+ this.handleSignUp = this.handleSignUp.bind(this);
+ this.handleSignIn = this.handleSignIn.bind(this);
+ this.handleChange = this.handleChange.bind(this);
+ this.handleChangeEmail = this.handleChangeEmail.bind(this);
+ this.handleResendVerification = this.handleResendVerification.bind(this);
+ }
+
+ static propTypes = {
+ requireEmailConfirmation: PropTypes.bool.isRequired
+ };
+
+ componentWillMount() {
+ this.props.checkLogin();
+ }
+
+ componentDidMount() {
+ window.addEventListener('storage', this.handleAuth);
+
+ const {formData} = this.state;
+ const errors = Object.keys(formData).reduce((map, prop) => {
+ map[prop] = lang.t('signIn.requiredField');
+ return map;
+ }, {});
+ this.setState({errors});
+ }
+
+ componentWillUnmount() {
+ window.removeEventListener('storage', this.handleAuth);
+ }
+
+ handleAuth(e) {
+
+ // Listening to FB changes
+ // FB localStorage key is 'auth'
+ const authCallback = this.props.facebookCallback;
+
+ if (e.key === 'auth') {
+ const {err, data} = JSON.parse(e.newValue);
+ authCallback(err, data);
+ }
+ }
+
+ handleChange(e) {
+ const {name, value} = e.target;
+ this.setState(
+ (state) => ({
+ ...state,
+ formData: {
+ ...state.formData,
+ [name]: value
+ }
+ }),
+ () => {
+ this.validation(name, value);
+ }
+ );
+ }
+
+ handleChangeEmail(e) {
+ const {value} = e.target;
+ this.setState({emailToBeResent: value});
+ }
+
+ handleResendVerification(e) {
+ e.preventDefault();
+ this.props
+ .requestConfirmEmail(
+ this.state.emailToBeResent,
+ pym.parentUrl || location.href
+ )
+ .then(() => {
+ setTimeout(() => {
+
+ // allow success UI to be shown for a second, and then close the modal
+ this.props.handleClose();
+ }, 2500);
+ });
+ }
+
+ addError(name, error) {
+ return this.setState((state) => ({
+ errors: {
+ ...state.errors,
+ [name]: error
+ }
+ }));
+ }
+
+ validation(name, value) {
+ const {addError} = this;
+ const {formData} = this.state;
+
+ if (!value.length) {
+ addError(name, lang.t('signIn.requiredField'));
+ } else if (
+ name === 'confirmPassword' &&
+ formData.confirmPassword !== formData.password
+ ) {
+ addError('confirmPassword', lang.t('signIn.passwordsDontMatch'));
+ } else if (!validate[name](value)) {
+ addError(name, errorMsj[name]);
+ } else {
+ const {[name]: prop, ...errors} = this.state.errors; // eslint-disable-line
+ // Removes Error
+ this.setState((state) => ({...state, errors}));
+ }
+ }
+
+ isCompleted() {
+ const {formData} = this.state;
+ return !Object.keys(formData).filter((prop) => !formData[prop].length).length;
+ }
+
+ displayErrors(show = true) {
+ this.setState({showErrors: show});
+ }
+
+ handleSignUp(e) {
+ e.preventDefault();
+ const {errors} = this.state;
+ const {fetchSignUp, validForm, invalidForm} = this.props;
+ this.displayErrors();
+ if (this.isCompleted() && !Object.keys(errors).length) {
+ fetchSignUp(this.state.formData, pym.parentUrl || location.href);
+ validForm();
+ } else {
+ invalidForm(lang.t('signIn.checkTheForm'));
+ }
+ }
+
+ handleSignIn(e) {
+ e.preventDefault();
+ this.props.fetchSignIn(this.state.formData);
+ }
+
+ render() {
+ const {auth, requireEmailConfirmation} = this.props;
+ const {emailVerificationLoading, emailVerificationSuccess} = auth;
+
+ return (
+
+ This is my login
+
+ );
+ }
+}
+
+const mapStateToProps = (state) => ({
+ auth: state.auth.toJS()
+});
+
+const mapDispatchToProps = (dispatch) => ({
+ checkLogin: () => dispatch(checkLogin()),
+ facebookCallback: (err, data) => dispatch(facebookCallback(err, data)),
+ fetchSignUp: (formData, url) => dispatch(fetchSignUp(formData, url)),
+ fetchSignIn: (formData) => dispatch(fetchSignIn(formData)),
+ fetchSignInFacebook: () => dispatch(fetchSignInFacebook()),
+ fetchSignUpFacebook: () => dispatch(fetchSignUpFacebook()),
+ fetchForgotPassword: (formData) => dispatch(fetchForgotPassword(formData)),
+ requestConfirmEmail: (email, url) =>
+ dispatch(requestConfirmEmail(email, url)),
+ changeView: (view) => dispatch(changeView(view)),
+ handleClose: () => dispatch(hideSignInDialog()),
+ invalidForm: (error) => dispatch(invalidForm(error)),
+ validForm: () => dispatch(validForm())
+});
+
+export default connect(mapStateToProps, mapDispatchToProps)(SignInContainer);
diff --git a/plugins/coral-plugin-auth/client/index.js b/plugins/coral-plugin-auth/client/index.js
index ff601992b..8d2eecc3c 100644
--- a/plugins/coral-plugin-auth/client/index.js
+++ b/plugins/coral-plugin-auth/client/index.js
@@ -1,7 +1,9 @@
import SignInButton from './components/SignInButton';
+import SignInContainer from './components/SignInContainer';
export default {
slots: {
- stream: [SignInButton]
+ stream: [SignInButton],
+ login: [SignInContainer]
}
};
\ No newline at end of file