diff --git a/common.js b/common.js index d91d974bd..a54adb2bc 100644 --- a/common.js +++ b/common.js @@ -127,5 +127,10 @@ export default { return false; } return true; + }, + + isEmailAddress: (email) => { + var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + return re.test(email); } }; diff --git a/components/User/SSO.js b/components/User/SSO.js index 367859968..b34517563 100644 --- a/components/User/SSO.js +++ b/components/User/SSO.js @@ -8,6 +8,7 @@ import {hashPassword} from '../../configs/general'; import instances from '../../configs/instances.js'; import SSOSingIn from '../../actions/user/SSOSingIn'; import {FormattedMessage, defineMessages} from 'react-intl'; +import {Accordion, Icon} from 'semantic-ui-react'; const MODI = 'sso_modi'; const NAME = 'sso_data'; @@ -17,7 +18,8 @@ class SSO extends React.Component { super(props); this.state = { - grecaptcharesponse: null + grecaptcharesponse: null, + activeIndex: 0 }; this.errorMessages = defineMessages({ @@ -68,7 +70,7 @@ class SSO extends React.Component { $(ReactDOM.findDOMNode(this.refs.SSO_form)).form(validationRules); - if (!instances[this.props.SSOStore.instance]) { + if (this.props.SSOStore && !instances[this.props.SSOStore.instance]) { console.log('Wrong instance name:', this.props.SSOStore.instance); swal({ title: 'Problem with the URL', @@ -120,42 +122,90 @@ class SSO extends React.Component { }); } + handleAccordionClick(e, titleProps) { + e.preventDefault(); + + const { index } = titleProps; + const { activeIndex } = this.state; + const newIndex = activeIndex === index ? -1 : index; + + this.setState({ activeIndex: newIndex }); + } + render() { const signUpLabelStyle = {width: '150px'}; const recaptchaStyle = {display: 'inline-block'}; const PUBLIC_KEY = '6LdNLyYTAAAAAINDsVZRKG_E3l3Dvpp5sKboR1ET'; // Public reCAPTCHA key let url = ''; - if (instances[this.props.SSOStore.instance]) + let redirect = ''; + if (this.props.SSOStore && instances[this.props.SSOStore.instance]) { url = instances[this.props.SSOStore.instance].url; + redirect = instances[this.props.SSOStore.instance].validate; + } + + const { activeIndex } = this.state; return (
+ SlideWiki wants to access your account on {instances[instances._self].url} in order to retrieve your account details to the SlideWiki on {url}.
+
+ Beneath you have to enter your password and your account with the email {(this.props.SSOStore) ? this.props.SSOStore.email : ''} will be copied to {url}.
+