mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
fix base-components user accounts
This commit is contained in:
parent
929352619f
commit
da2d9c2b81
6 changed files with 11 additions and 118 deletions
|
@ -66,5 +66,4 @@ import './users/UsersAvatar.jsx';
|
|||
import './users/UsersName.jsx';
|
||||
import './users/UsersMenu.jsx';
|
||||
import './users/UsersAccountMenu.jsx';
|
||||
import './users/UsersAccountForm.jsx';
|
||||
import './users/UsersResetPassword.jsx';
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
import { getSetting } from 'meteor/vulcan:core';
|
||||
import Users from 'meteor/vulcan:users';
|
||||
import { T9n } from 'meteor/softwarerero:accounts-t9n';
|
||||
|
||||
Users.avatar.setOptions({
|
||||
"gravatarDefault": "mm",
|
||||
"defaultImageUrl": "http://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&f=y"
|
||||
});
|
||||
|
||||
// https://github.com/softwarerero/meteor-accounts-t9n
|
||||
T9n.setLanguage(getSetting("locale", "en"));
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
import { registerComponent, withCurrentUser } from 'meteor/vulcan:core';
|
||||
import React, { PropTypes, Component } from 'react';
|
||||
import { Button, FormControl } from 'react-bootstrap';
|
||||
import { Accounts } from 'meteor/std:accounts-ui';
|
||||
import { withApollo } from 'react-apollo';
|
||||
|
||||
const UsersAccountForm = ({client, currentUser}) => {
|
||||
return (
|
||||
<Accounts.ui.LoginForm
|
||||
user={currentUser}
|
||||
onPostSignUpHook={() => client.resetStore()}
|
||||
onSignedInHook={() => client.resetStore()}
|
||||
onSignedOutHook={() => client.resetStore()}
|
||||
/>
|
||||
)
|
||||
};
|
||||
|
||||
registerComponent('UsersAccountForm', UsersAccountForm, withCurrentUser, withApollo);
|
||||
|
||||
// customize Accounts.ui
|
||||
|
||||
Accounts.ui.config({
|
||||
passwordSignupFields: 'USERNAME_AND_EMAIL',
|
||||
});
|
||||
|
||||
class AccountsButton extends Accounts.ui.Button {
|
||||
render () {
|
||||
const {label, href, type, disabled, className, onClick} = this.props;
|
||||
if (type === 'link') {
|
||||
return <a href={ href } className={ className } onClick={ onClick }>{ label }</a>;
|
||||
}
|
||||
return <Button
|
||||
bsStyle="primary"
|
||||
className={ className }
|
||||
type={ type }
|
||||
disabled={ disabled }
|
||||
onClick={ onClick }>{ label }
|
||||
</Button>;
|
||||
}
|
||||
}
|
||||
|
||||
class AccountsField extends Accounts.ui.Field {
|
||||
|
||||
render() {
|
||||
const { id, hint, /* label, */ type = 'text', onChange, className = "field", defaultValue = "", message } = this.props;
|
||||
const { mount = true } = this.state;
|
||||
return mount ? (
|
||||
<div className={ className }>
|
||||
<FormControl id={ id } type={ type } inputRef={ref => { this.input = ref; }} onChange={ onChange } placeholder={ hint } defaultValue={ defaultValue } />
|
||||
{message && (
|
||||
<span className={['message', message.type].join(' ').trim()}>
|
||||
{message.message}</span>
|
||||
)}
|
||||
</div>
|
||||
) : null;
|
||||
}
|
||||
}
|
||||
|
||||
// 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>
|
||||
// );
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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 = [];
|
||||
// }
|
||||
|
||||
// if (hasPasswordService && labels.length > 0) {
|
||||
// return (
|
||||
// <div style={ style } className={ className }>
|
||||
// { `${T9n.get('or use')} ${ labels.join(' / ') }` }
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
Accounts.ui.Button = AccountsButton;
|
||||
Accounts.ui.Field = AccountsField;
|
||||
// Accounts.ui.SocialButtons = AccountsSocialButtons;
|
||||
// Accounts.ui.PasswordOrService = AccountsPasswordOrService;
|
|
@ -11,7 +11,7 @@ const UsersAccountMenu = () => {
|
|||
<FormattedMessage id="users.log_in"/>
|
||||
</Dropdown.Toggle>
|
||||
<Dropdown.Menu>
|
||||
<Components.UsersAccountForm />
|
||||
<Components.AccountsLoginForm />
|
||||
</Dropdown.Menu>
|
||||
</Dropdown>
|
||||
)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { registerComponent, withCurrentUser } from 'meteor/vulcan:core';
|
||||
import { Components, registerComponent, withCurrentUser } from 'meteor/vulcan:core';
|
||||
import React, { Component } from 'react';
|
||||
import { Accounts, STATES } from 'meteor/std:accounts-ui';
|
||||
import { T9n } from 'meteor/softwarerero:accounts-t9n';
|
||||
import { Link } from 'react-router';
|
||||
import { intlShape } from 'react-intl';
|
||||
|
||||
class UsersResetPassword extends Component {
|
||||
componentDidMount() {
|
||||
|
@ -13,15 +12,15 @@ class UsersResetPassword extends Component {
|
|||
render() {
|
||||
if (!this.props.currentUser) {
|
||||
return (
|
||||
<Accounts.ui.LoginForm
|
||||
formState={ STATES.PASSWORD_CHANGE }
|
||||
<Components.AccountsLoginForm
|
||||
formState={ Symbol('PASSWORD_CHANGE') }
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='password-reset-form'>
|
||||
<div>{T9n.get('info.passwordChanged')}!</div>
|
||||
<div>{this.context.intl.formatMessage({id: 'accounts.info_password_changed'})}!</div>
|
||||
<Link to="/">
|
||||
Return Home
|
||||
</Link>
|
||||
|
@ -30,6 +29,9 @@ class UsersResetPassword extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
UsersResetPassword.contextTypes = {
|
||||
intl: intlShape
|
||||
}
|
||||
|
||||
UsersResetPassword.propsTypes = {
|
||||
currentUser: React.PropTypes.object,
|
||||
|
|
|
@ -15,11 +15,10 @@ Package.onUse(function (api) {
|
|||
'vulcan:posts@1.3.0',
|
||||
'vulcan:comments@1.3.0',
|
||||
'vulcan:voting@1.3.0',
|
||||
|
||||
'vulcan:accounts@1.3.0',
|
||||
|
||||
// third-party packages
|
||||
'fortawesome:fontawesome@4.5.0',
|
||||
'tmeasday:check-npm-versions@0.3.1',
|
||||
'std:accounts-ui@1.2.19',
|
||||
]);
|
||||
|
||||
api.mainModule("lib/server.js", "server");
|
||||
|
|
Loading…
Add table
Reference in a new issue