mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +01:00
Work on signup/login
This commit is contained in:
parent
b4f1d3d6cc
commit
4af174dffb
@ -11,6 +11,7 @@ import UserActions from '../../actions/user_actions';
|
|||||||
|
|
||||||
import Form from './form';
|
import Form from './form';
|
||||||
import Property from './property';
|
import Property from './property';
|
||||||
|
import FormPropertyHeader from './form_property_header';
|
||||||
|
|
||||||
import apiUrls from '../../constants/api_urls';
|
import apiUrls from '../../constants/api_urls';
|
||||||
import AppConstants from '../../constants/application_constants';
|
import AppConstants from '../../constants/application_constants';
|
||||||
@ -19,20 +20,25 @@ import { getLangText } from '../../utils/lang_utils';
|
|||||||
|
|
||||||
|
|
||||||
let LoginForm = React.createClass({
|
let LoginForm = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
headerMessage: React.PropTypes.string,
|
||||||
|
submitMessage: React.PropTypes.string,
|
||||||
redirectOnLoggedIn: React.PropTypes.bool,
|
redirectOnLoggedIn: React.PropTypes.bool,
|
||||||
redirectOnLoginSuccess: React.PropTypes.bool
|
redirectOnLoginSuccess: React.PropTypes.bool
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mixins: [Router.Navigation],
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
return {
|
return {
|
||||||
|
headerMessage: 'Enter ascribe',
|
||||||
|
submitMessage: 'Log in',
|
||||||
redirectOnLoggedIn: true,
|
redirectOnLoggedIn: true,
|
||||||
redirectOnLoginSuccess: true
|
redirectOnLoginSuccess: true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [Router.Navigation],
|
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return UserStore.getState();
|
return UserStore.getState();
|
||||||
},
|
},
|
||||||
@ -80,6 +86,7 @@ let LoginForm = React.createClass({
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
|
className="ascribe-form-bordered"
|
||||||
ref="loginForm"
|
ref="loginForm"
|
||||||
url={apiUrls.users_login}
|
url={apiUrls.users_login}
|
||||||
handleSuccess={this.handleSuccess}
|
handleSuccess={this.handleSuccess}
|
||||||
@ -87,13 +94,16 @@ let LoginForm = React.createClass({
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="btn ascribe-btn ascribe-btn-login">
|
className="btn ascribe-btn ascribe-btn-login">
|
||||||
{getLangText('Enter')} ascribe
|
{getLangText(this.props.submitMessage)}
|
||||||
</button>}
|
</button>}
|
||||||
spinner={
|
spinner={
|
||||||
<button className="btn ascribe-btn ascribe-btn-login ascribe-btn-login-spinner">
|
<button className="btn ascribe-btn ascribe-btn-login ascribe-btn-login-spinner">
|
||||||
<img src="https://s3-us-west-2.amazonaws.com/ascribe0/media/thumbnails/ascribe_animated_medium.gif" />
|
<img src="https://s3-us-west-2.amazonaws.com/ascribe0/media/thumbnails/ascribe_animated_medium.gif" />
|
||||||
</button>
|
</button>
|
||||||
}>
|
}>
|
||||||
|
<FormPropertyHeader>
|
||||||
|
<h3>{getLangText(this.props.headerMessage)}</h3>
|
||||||
|
</FormPropertyHeader>
|
||||||
<Property
|
<Property
|
||||||
name='email'
|
name='email'
|
||||||
label={getLangText('Email')}>
|
label={getLangText('Email')}>
|
||||||
@ -114,7 +124,6 @@ let LoginForm = React.createClass({
|
|||||||
name="password"
|
name="password"
|
||||||
required/>
|
required/>
|
||||||
</Property>
|
</Property>
|
||||||
<hr />
|
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,20 @@ import apiUrls from '../../constants/api_urls';
|
|||||||
let SignupForm = React.createClass({
|
let SignupForm = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
headerMessage: React.PropTypes.string,
|
||||||
|
submitMessage: React.PropTypes.string,
|
||||||
handleSuccess: React.PropTypes.func
|
handleSuccess: React.PropTypes.func
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [Router.Navigation],
|
mixins: [Router.Navigation],
|
||||||
|
|
||||||
|
getDefaultProps() {
|
||||||
|
return {
|
||||||
|
headerMessage: 'Welcome to ascribe',
|
||||||
|
submitMessage: 'Sign up'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return UserStore.getState();
|
return UserStore.getState();
|
||||||
},
|
},
|
||||||
@ -72,7 +81,7 @@ let SignupForm = React.createClass({
|
|||||||
getFormData={this.getFormData}
|
getFormData={this.getFormData}
|
||||||
buttons={
|
buttons={
|
||||||
<button type="submit" className="btn ascribe-btn ascribe-btn-login">
|
<button type="submit" className="btn ascribe-btn ascribe-btn-login">
|
||||||
{getLangText('Sign up to ascribe')}
|
{getLangText(this.props.submitMessage)}
|
||||||
</button>}
|
</button>}
|
||||||
spinner={
|
spinner={
|
||||||
<button className="btn ascribe-btn ascribe-btn-login ascribe-btn-login-spinner">
|
<button className="btn ascribe-btn ascribe-btn-login ascribe-btn-login-spinner">
|
||||||
@ -80,7 +89,7 @@ let SignupForm = React.createClass({
|
|||||||
</button>
|
</button>
|
||||||
}>
|
}>
|
||||||
<FormPropertyHeader>
|
<FormPropertyHeader>
|
||||||
<h3>{getLangText('Welcome to ascribe')}</h3>
|
<h3>{getLangText(this.props.headerMessage)}</h3>
|
||||||
</FormPropertyHeader>
|
</FormPropertyHeader>
|
||||||
<Property
|
<Property
|
||||||
name='email'
|
name='email'
|
||||||
|
@ -24,7 +24,6 @@ let LoginContainer = React.createClass({
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="ascribe-login-wrapper">
|
<div className="ascribe-login-wrapper">
|
||||||
<br/>
|
|
||||||
<LoginForm
|
<LoginForm
|
||||||
message={this.props.message} />
|
message={this.props.message} />
|
||||||
<div className="ascribe-login-text">
|
<div className="ascribe-login-text">
|
||||||
|
@ -39,7 +39,7 @@ let PasswordResetContainer = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="ascribe-login-text ascribe-login-header">
|
<div className="ascribe-login-text ascribe-login-header">
|
||||||
{getLangText('Reset your ascribe password')}
|
{getLangText('Reset your password')}
|
||||||
</div>
|
</div>
|
||||||
<PasswordRequestResetForm
|
<PasswordRequestResetForm
|
||||||
handleRequestSuccess={this.handleRequestSuccess}/>
|
handleRequestSuccess={this.handleRequestSuccess}/>
|
||||||
@ -157,4 +157,4 @@ let PasswordResetForm = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default PasswordResetContainer;
|
export default PasswordResetContainer;
|
||||||
|
27
js/components/whitelabel/prize/components/login_container.js
Normal file
27
js/components/whitelabel/prize/components/login_container.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import Router from 'react-router';
|
||||||
|
|
||||||
|
import LoginForm from '../../../ascribe_forms/form_login';
|
||||||
|
|
||||||
|
let Link = Router.Link;
|
||||||
|
|
||||||
|
|
||||||
|
let LoginContainer = React.createClass({
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div className="ascribe-login-wrapper">
|
||||||
|
<LoginForm headerMessage="Log in" />
|
||||||
|
<div className="ascribe-login-text">
|
||||||
|
I'm not a user <Link to="signup">Sign up...</Link><br/>
|
||||||
|
I forgot my password <Link to="password_reset">Rescue me...</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default LoginContainer;
|
@ -0,0 +1,45 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import SignupForm from '../../../ascribe_forms/form_signup';
|
||||||
|
|
||||||
|
|
||||||
|
let SignupContainer = React.createClass({
|
||||||
|
getInitialState() {
|
||||||
|
return {
|
||||||
|
submitted: false,
|
||||||
|
message: null
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSuccess(message){
|
||||||
|
this.setState({
|
||||||
|
submitted: true,
|
||||||
|
message: message
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.state.submitted){
|
||||||
|
return (
|
||||||
|
<div className="ascribe-login-wrapper">
|
||||||
|
<br/>
|
||||||
|
<div className="ascribe-login-text ascribe-login-header">
|
||||||
|
{this.state.message}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className="ascribe-login-wrapper">
|
||||||
|
<SignupForm
|
||||||
|
headerMessage="Sign up to the prize"
|
||||||
|
submitMessage="Sign up"
|
||||||
|
handleSuccess={this.handleSuccess}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
export default SignupContainer;
|
@ -4,6 +4,9 @@ import React from 'react';
|
|||||||
import Router from 'react-router';
|
import Router from 'react-router';
|
||||||
|
|
||||||
import Landing from './components/landing';
|
import Landing from './components/landing';
|
||||||
|
import LoginContainer from './components/login_container';
|
||||||
|
import SignupContainer from './components/signup_container';
|
||||||
|
import PasswordResetContainer from '../../../components/password_reset_container';
|
||||||
|
|
||||||
import App from './app';
|
import App from './app';
|
||||||
import AppConstants from '../../../constants/application_constants';
|
import AppConstants from '../../../constants/application_constants';
|
||||||
@ -16,8 +19,9 @@ function getRoutes(commonRoutes) {
|
|||||||
return (
|
return (
|
||||||
<Route name="app" path={baseUrl} handler={App}>
|
<Route name="app" path={baseUrl} handler={App}>
|
||||||
<Route name="landing" path="/" handler={Landing} />
|
<Route name="landing" path="/" handler={Landing} />
|
||||||
|
<Route name="login" path="login" handler={LoginContainer} />
|
||||||
{commonRoutes}
|
<Route name="signup" path="signup" handler={SignupContainer} />
|
||||||
|
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
|
||||||
</Route>
|
</Route>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user