2016-04-03 11:42:07 +09:00
|
|
|
|
import React, { PropTypes, Component } from 'react';
|
2016-04-21 15:08:43 +09:00
|
|
|
|
import { Button, FormControl } from 'react-bootstrap';
|
2016-04-03 11:42:07 +09:00
|
|
|
|
import { Accounts } from 'meteor/std:accounts-ui';
|
|
|
|
|
|
2016-11-08 12:58:53 +01:00
|
|
|
|
//import { client } from 'meteor/nova:apollo';
|
2016-10-30 18:25:51 +01:00
|
|
|
|
|
2016-04-19 16:14:41 +09:00
|
|
|
|
const UsersAccountForm = () => {
|
2016-04-03 11:42:07 +09:00
|
|
|
|
return (
|
|
|
|
|
<Accounts.ui.LoginForm />
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
|
2016-04-19 16:14:41 +09:00
|
|
|
|
module.exports = UsersAccountForm;
|
|
|
|
|
export default UsersAccountForm;
|
2016-04-03 11:42:07 +09:00
|
|
|
|
|
|
|
|
|
// customize Accounts.ui
|
|
|
|
|
|
|
|
|
|
Accounts.ui.config({
|
|
|
|
|
passwordSignupFields: 'USERNAME_AND_EMAIL',
|
2016-11-10 10:54:43 +01:00
|
|
|
|
onPostSignUpHook: () => Telescope.graphQL.client.resetStore(),
|
|
|
|
|
onSignedInHook: () => Telescope.graphQL.client.resetStore(),
|
|
|
|
|
onSignedOutHook: () => Telescope.graphQL.client.resetStore(),
|
2016-04-03 11:42:07 +09:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
class AccountsButton extends Accounts.ui.Button {
|
2016-04-04 11:30:14 +09:00
|
|
|
|
render () {
|
|
|
|
|
const {label, href, type, disabled, className, onClick} = this.props;
|
|
|
|
|
if (type === 'link') {
|
|
|
|
|
return <a href={ href } className={ className } onClick={ onClick }>{ label }</a>;
|
2016-04-03 11:42:07 +09:00
|
|
|
|
}
|
2016-04-04 11:30:14 +09:00
|
|
|
|
return <Button
|
|
|
|
|
bsStyle="primary"
|
|
|
|
|
className={ className }
|
|
|
|
|
type={ type }
|
|
|
|
|
disabled={ disabled }
|
|
|
|
|
onClick={ onClick }>{ label }
|
|
|
|
|
</Button>;
|
2016-04-03 11:42:07 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AccountsField extends Accounts.ui.Field {
|
2016-08-25 09:54:02 +09:00
|
|
|
|
|
|
|
|
|
// see https://github.com/studiointeract/accounts-ui/issues/60
|
|
|
|
|
triggerUpdate () {
|
|
|
|
|
const { onChange } = this.props
|
|
|
|
|
if (this.input) {
|
|
|
|
|
onChange({ target: { value: this.input.value } })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-03 11:42:07 +09:00
|
|
|
|
render() {
|
|
|
|
|
const { id, hint, label, type = 'text', onChange, className = "field", defaultValue = "" } = this.props;
|
|
|
|
|
const { mount = true } = this.state;
|
|
|
|
|
return mount ? (
|
|
|
|
|
<div className={ className }>
|
2016-04-21 15:08:43 +09:00
|
|
|
|
<FormControl id={ id } type={ type } onChange={ onChange } placeholder={ hint } defaultValue={ defaultValue } />
|
2016-04-03 11:42:07 +09:00
|
|
|
|
</div>
|
|
|
|
|
) : null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-03 11:49:34 +09:00
|
|
|
|
// class AccountsSocialButtons extends Accounts.ui.SocialButtons {
|
|
|
|
|
// render () {
|
|
|
|
|
// let { oauthServices = {}, className = "social_buttons" } = this.props;
|
|
|
|
|
// return(
|
|
|
|
|
// <div className={ className }>
|
|
|
|
|
// {Object.keys(oauthServices)
|
|
|
|
|
// .filter(service => oauthServices[service].disabled) // filter services registered but not enabled
|
|
|
|
|
// .map((id, i) => <Accounts.ui.Button {...oauthServices[id]} key={i} />)}
|
|
|
|
|
// </div>
|
|
|
|
|
// );
|
2016-04-03 11:42:07 +09:00
|
|
|
|
|
2016-04-03 11:49:34 +09:00
|
|
|
|
// }
|
|
|
|
|
// }
|
2016-04-03 11:42:07 +09:00
|
|
|
|
|
2016-04-03 11:49:34 +09:00
|
|
|
|
// class AccountsPasswordOrService extends Accounts.ui.PasswordOrService {
|
|
|
|
|
// render () {
|
|
|
|
|
// let {
|
|
|
|
|
// oauthServices = {},
|
|
|
|
|
// className,
|
|
|
|
|
// style = {}
|
|
|
|
|
// } = this.props;
|
|
|
|
|
// let { hasPasswordService } = this.state;
|
|
|
|
|
// let labels = Object.keys(oauthServices)
|
|
|
|
|
// .filter(service => oauthServices[service].disabled) // filter services registered but not enabled
|
|
|
|
|
// .map(service => oauthServices[service].label);
|
|
|
|
|
// if (labels.length > 2) {
|
|
|
|
|
// labels = [];
|
|
|
|
|
// }
|
2016-04-03 11:42:07 +09:00
|
|
|
|
|
2016-04-03 11:49:34 +09:00
|
|
|
|
// if (hasPasswordService && labels.length > 0) {
|
|
|
|
|
// return (
|
|
|
|
|
// <div style={ style } className={ className }>
|
|
|
|
|
// { `${T9n.get('or use')} ${ labels.join(' / ') }` }
|
|
|
|
|
// </div>
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2016-04-03 11:42:07 +09:00
|
|
|
|
|
|
|
|
|
Accounts.ui.Button = AccountsButton;
|
|
|
|
|
Accounts.ui.Field = AccountsField;
|
2016-04-03 11:49:34 +09:00
|
|
|
|
// Accounts.ui.SocialButtons = AccountsSocialButtons;
|
|
|
|
|
// Accounts.ui.PasswordOrService = AccountsPasswordOrService;
|