mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
password reset
modal switch problems
This commit is contained in:
parent
66f8a6a1ca
commit
56d32efcc0
@ -7,6 +7,9 @@ import FormMixin from '../../mixins/form_mixin';
|
|||||||
import InputText from './input_text';
|
import InputText from './input_text';
|
||||||
import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close';
|
import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close';
|
||||||
|
|
||||||
|
import SignupModal from '../ascribe_modal/modal_signup';
|
||||||
|
import PasswordResetRequestModal from '../ascribe_modal/modal_password_request_reset';
|
||||||
|
|
||||||
let LoginForm = React.createClass({
|
let LoginForm = React.createClass({
|
||||||
mixins: [FormMixin],
|
mixins: [FormMixin],
|
||||||
|
|
||||||
@ -21,7 +24,6 @@ let LoginForm = React.createClass({
|
|||||||
password: this.refs.password.state.value
|
password: this.refs.password.state.value
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
renderForm() {
|
renderForm() {
|
||||||
return (
|
return (
|
||||||
<form id="login_modal_content" role="form" onSubmit={this.submit}>
|
<form id="login_modal_content" role="form" onSubmit={this.submit}>
|
||||||
@ -40,10 +42,14 @@ let LoginForm = React.createClass({
|
|||||||
type="password"
|
type="password"
|
||||||
submitted={this.state.submitted}/>
|
submitted={this.state.submitted}/>
|
||||||
<div>
|
<div>
|
||||||
Forgot your password? <a className="button" href="#" id="request_reset_pwd_from_login_btn">Reset password</a>.
|
Forgot your password?
|
||||||
|
<PasswordResetRequestModal
|
||||||
|
button={<a className="button" href="#"> Reset password</a>}/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Not a member yet? <a className="button" href="#" id="signup_from_login_btn">Sign up</a>.
|
Not a member yet?
|
||||||
|
<SignupModal
|
||||||
|
button={<a className="button" href="#"> Sign up</a>}/>
|
||||||
</div>
|
</div>
|
||||||
<ButtonSubmitOrClose
|
<ButtonSubmitOrClose
|
||||||
text="LOGIN"
|
text="LOGIN"
|
||||||
|
@ -60,8 +60,7 @@ let SignupForm = React.createClass({
|
|||||||
<div>
|
<div>
|
||||||
I agree to the
|
I agree to the
|
||||||
<a href="/terms" target="_blank"> Terms of Service</a>
|
<a href="/terms" target="_blank"> Terms of Service</a>
|
||||||
</div>}
|
</div>}/>
|
||||||
/>)
|
|
||||||
<InputText
|
<InputText
|
||||||
ref="promo_code"
|
ref="promo_code"
|
||||||
placeHolder="Promocode (Optional)"
|
placeHolder="Promocode (Optional)"
|
||||||
|
32
js/components/ascribe_modal/modal_login.js
Normal file
32
js/components/ascribe_modal/modal_login.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import ModalWrapper from './modal_wrapper';
|
||||||
|
import LoginForm from '../ascribe_forms/form_login';
|
||||||
|
|
||||||
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
|
let LoginModal = React.createClass({
|
||||||
|
handleLoginSuccess(){
|
||||||
|
this.props.handleSuccess();
|
||||||
|
let notificationText = 'Login successful';
|
||||||
|
let notification = new GlobalNotificationModel(notificationText, 'success');
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<ModalWrapper
|
||||||
|
button={this.props.button}
|
||||||
|
title='Log in to ascribe'
|
||||||
|
handleSuccess={this.handleLoginSuccess}
|
||||||
|
tooltip='Log in to ascribe'>
|
||||||
|
<LoginForm />
|
||||||
|
</ModalWrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default LoginModal;
|
30
js/components/ascribe_modal/modal_password_request_reset.js
Normal file
30
js/components/ascribe_modal/modal_password_request_reset.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import ModalWrapper from './modal_wrapper';
|
||||||
|
import PasswordResetRequestForm from '../ascribe_forms/form_password_reset_request';
|
||||||
|
|
||||||
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
|
let PasswordResetRequestModal = React.createClass({
|
||||||
|
handleResetSuccess(){
|
||||||
|
let notificationText = 'Request succesfully sent, check your email';
|
||||||
|
let notification = new GlobalNotificationModel(notificationText, 'success', 50000);
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<ModalWrapper
|
||||||
|
button={this.props.button}
|
||||||
|
title='Reset your password'
|
||||||
|
handleSuccess={this.handleResetSuccess}
|
||||||
|
tooltip='Reset your password'>
|
||||||
|
<PasswordResetRequestForm />
|
||||||
|
</ModalWrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default PasswordResetRequestModal;
|
31
js/components/ascribe_modal/modal_signup.js
Normal file
31
js/components/ascribe_modal/modal_signup.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import ModalWrapper from './modal_wrapper';
|
||||||
|
import SignupForm from '../ascribe_forms/form_signup';
|
||||||
|
|
||||||
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
|
let SignupModal = React.createClass({
|
||||||
|
handleSignupSuccess(response){
|
||||||
|
let notificationText = 'We sent an email to your address ' + response.user.email + ', please confirm.';
|
||||||
|
let notification = new GlobalNotificationModel(notificationText, 'success', 50000);
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<ModalWrapper
|
||||||
|
button={this.props.button}
|
||||||
|
title='Create an account'
|
||||||
|
handleSuccess={this.handleSignupSuccess}
|
||||||
|
tooltip='Sign up to ascribe'>
|
||||||
|
<SignupForm />
|
||||||
|
</ModalWrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default SignupModal;
|
@ -7,7 +7,6 @@ import UserActions from '../actions/user_actions';
|
|||||||
import UserStore from '../stores/user_store';
|
import UserStore from '../stores/user_store';
|
||||||
|
|
||||||
import apiUrls from '../constants/api_urls.js';
|
import apiUrls from '../constants/api_urls.js';
|
||||||
|
|
||||||
import PieceListActions from '../actions/piece_list_actions';
|
import PieceListActions from '../actions/piece_list_actions';
|
||||||
|
|
||||||
import Nav from 'react-bootstrap/lib/Nav';
|
import Nav from 'react-bootstrap/lib/Nav';
|
||||||
@ -16,8 +15,9 @@ import NavItem from 'react-bootstrap/lib/NavItem';
|
|||||||
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
|
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
|
||||||
import MenuItem from 'react-bootstrap/lib/MenuItem';
|
import MenuItem from 'react-bootstrap/lib/MenuItem';
|
||||||
|
|
||||||
import ModalWrapper from '../components/ascribe_modal/modal_wrapper';
|
import LoginModal from '../components/ascribe_modal/modal_login';
|
||||||
import LoginForm from '../components/ascribe_forms/form_login';
|
import SignupModal from '../components/ascribe_modal/modal_signup';
|
||||||
|
|
||||||
|
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
|
|
||||||
@ -41,20 +41,14 @@ let Header = React.createClass({
|
|||||||
onChange(state) {
|
onChange(state) {
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
},
|
},
|
||||||
handleLoginSuccess(){
|
|
||||||
|
refreshData(){
|
||||||
UserActions.fetchCurrentUser();
|
UserActions.fetchCurrentUser();
|
||||||
PieceListActions.fetchPieceList(1, 10);
|
PieceListActions.fetchPieceList(1, 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let account = (
|
let account = null;
|
||||||
<ModalWrapper
|
let signup = null;
|
||||||
button={<NavItem to="pieces">LOGIN</NavItem>}
|
|
||||||
title='Log in to ascribe'
|
|
||||||
handleSuccess={this.handleLoginSuccess}
|
|
||||||
tooltip='Log in to ascribe'>
|
|
||||||
<LoginForm />
|
|
||||||
</ModalWrapper>);
|
|
||||||
if (this.state.currentUser.username){
|
if (this.state.currentUser.username){
|
||||||
account = (
|
account = (
|
||||||
<DropdownButton eventKey="1" title={this.state.currentUser.username}>
|
<DropdownButton eventKey="1" title={this.state.currentUser.username}>
|
||||||
@ -67,6 +61,15 @@ let Header = React.createClass({
|
|||||||
</DropdownButton>
|
</DropdownButton>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
account = (
|
||||||
|
<LoginModal
|
||||||
|
button={<NavItem to="pieces">LOGIN</NavItem>}
|
||||||
|
handleSuccess={this.refreshData}/>);
|
||||||
|
signup = (
|
||||||
|
<SignupModal
|
||||||
|
button={<NavItem to="pieces">SIGNUP</NavItem>} />);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Navbar>
|
<Navbar>
|
||||||
<Nav>
|
<Nav>
|
||||||
@ -77,6 +80,7 @@ let Header = React.createClass({
|
|||||||
</Nav>
|
</Nav>
|
||||||
<Nav right>
|
<Nav right>
|
||||||
{account}
|
{account}
|
||||||
|
{signup}
|
||||||
</Nav>
|
</Nav>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
);
|
);
|
||||||
|
@ -6,7 +6,7 @@ import Router from 'react-router';
|
|||||||
import AscribeApp from './components/ascribe_app';
|
import AscribeApp from './components/ascribe_app';
|
||||||
import PieceList from './components/piece_list';
|
import PieceList from './components/piece_list';
|
||||||
import EditionContainer from './components/edition_container';
|
import EditionContainer from './components/edition_container';
|
||||||
|
import PasswordResetForm from './components/ascribe_forms/form_password_reset';
|
||||||
import AppConstants from './constants/application_constants';
|
import AppConstants from './constants/application_constants';
|
||||||
|
|
||||||
let Route = Router.Route;
|
let Route = Router.Route;
|
||||||
@ -18,6 +18,7 @@ let routes = (
|
|||||||
<Route name="app" path={baseUrl} handler={AscribeApp}>
|
<Route name="app" path={baseUrl} handler={AscribeApp}>
|
||||||
<Route name="pieces" path="collection" handler={PieceList} />
|
<Route name="pieces" path="collection" handler={PieceList} />
|
||||||
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />
|
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />
|
||||||
|
<Route name="password_reset" path="password_reset" handler={PasswordResetForm} />
|
||||||
|
|
||||||
<Redirect from={baseUrl} to="pieces" />
|
<Redirect from={baseUrl} to="pieces" />
|
||||||
<Redirect from={baseUrl + '/'} to="pieces" />
|
<Redirect from={baseUrl + '/'} to="pieces" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user