2016-12-11 11 views
0

を通じてmeteor.jsでユーザーを作成するには:は、どのように私はコンポーネントの反応からユーザーを作成しようとしているreact.js

import React, { Component, PropTypes } from 'react'; 
import ReactDOM from 'react-dom'; 
import { Accounts } from 'meteor/accounts-base' 

import { createContainer } from 'meteor/react-meteor-data'; 

import { FlowRouter } from 'meteor/kadira:flow-router'; 
import { mount } from 'react-mounter'; 

FlowRouter.route('/signup', { name: 'signup', action(){ mount(SignUp); } }); 

AccountsTemplates.configure({ 
    forbidClientAccountCreation: false 
}); 

class SignUp extends Component { 
    constructor(props) { 
    super(props); 
    this.state = { mail:'', pass:''}; 
    } 
    handleMailChange(e){ this.setState({mail: e.target.value}); } 
    handlePassChange(e){ this.setState({pass: e.target.value}); } 
    eSignup(e){ 
    e.preventDefault(); 
    console.log("Sign Up Form submitted."); 
    Accounts.createUser({ email:'mail', password:'passwd'}, (err)=> { 
     if (err) console.error(err.reason); 
     else { 
     console.info('Create user success !'); 
     FlowRouter.go('/'); 
     } 
    }); 
    } 
    render(){ 
    return (
     <div className="row"> 
      <div className="container"> 
      <form name="login"> 
       <input type="email" name="mail" onChange={this.hMailChange.bind(this)}/> 
       <input type="password" name="Pass" onChange={this.hPassChange.bind(this)}/> 
       <input type="submit" value="Signup" onClick={this.Signup.bind(this)}/> 
      </form> 
      </div> 
     </div> 
    ); 
    } 
} 

しかし、私はエラーを取得する:403 Signups forbiddenを。 私は流星のコンポーネントのソースコードを調べました。そして多分私はそこにエラーが発生行見つける: https://github.com/meteor/accounts/blob/master/packages/accounts-password/password_server.js#L1014

if (Accounts._options.forbidClientAccountCreation) 
    return { error: new Meteor.Error(403, "Signups forbidden") }; 

をし、このテストは、私がaccount-uiや他のパッケージ

falseよう Accounts._options.forbidClientAccountCreationを設定している場合 uiusersで動作するように動作しますなぜ私は理解していません削除しました。

マイpackage.json

私が間違ってやっている何
"dependencies": { 
    "babel-runtime": "^6.18.0", 
    "bcrypt": "^1.0.1", 
    "classnames": "^2.2.5", 
    "lib": "^1.0.5", 
    "meteor-node-stubs": "~0.2.0", 
    "particles.js": "^2.0.0", 
    "react": "^15.4.1", 
    "react-addons-pure-render-mixin": "^15.4.1", 
    "react-dom": "^15.4.1", 
    "react-mounter": "^1.2.0" 
    } 

答えて

1

コードはforbidClientAccountCreationtrueのいずれかに設定されている必要があります。クライアントでユーザーを作成するには、このオプションをfalseに変更する必要があります。

import { AccountsCommon } from 'meteor/accounts-base' 

AccountsCommon.config({ 
    forbidClientAccountCreation: false 
}); 
関連する問題