├── LICENSE ├── README.md ├── package.js └── ra-login.js /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Adam Brodzinski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # meteor-react-login 2 | A set of compossible components to sign in / login / signin / reset password / dropdown 3 | -------------------------------------------------------------------------------- /package.js: -------------------------------------------------------------------------------- 1 | Package.describe({ 2 | name: 'skinnygeek1010:react-accounts', 3 | version: '0.1.0', 4 | summary: 'React Accounts', 5 | git: 'https://github.com/AdamBrodzinski/meteor-react-accounts.git', 6 | documentation: 'README.md' 7 | }); 8 | 9 | Package.onUse(function(api) { 10 | api.versionsFrom('1.0'); 11 | api.use('react'); 12 | api.addFiles('ra-login.js'); 13 | api.export('ReactAccounts'); 14 | }); 15 | -------------------------------------------------------------------------------- /ra-login.js: -------------------------------------------------------------------------------- 1 | /*global React, ReactAccounts:true */ 2 | /* jshint maxlen: false */ 3 | 4 | ReactAccounts = {}; 5 | var noop = function() {}; 6 | 7 | ReactAccounts.LoginForm = React.createClass({ 8 | getDefaultProps: function() { 9 | return { 10 | debug: true, 11 | type: "email-password", 12 | noValidate: true, 13 | formClassName: "ReactAccounts__form", 14 | onLoginError: noop, 15 | }; 16 | }, 17 | 18 | getInitialState: function() { 19 | return { 20 | loginErrMsg: "" 21 | }; 22 | }, 23 | 24 | dbug: function() { 25 | if (this.props.debug) { 26 | console.debug.apply(console, arguments); 27 | } 28 | }, 29 | 30 | handleSubmit: function(e) { 31 | e.preventDefault(); 32 | if (this.props.type === "email-password") { 33 | var email = this.refs.email.getDOMNode().value; 34 | var pass = this.refs.password.getDOMNode().value; 35 | this.loginWithPassword(email, pass); 36 | this.dbug("Form submit", email, pass, e); 37 | } 38 | }, 39 | 40 | loginWithPassword: function(email, pass) { 41 | var self = this; 42 | Meteor.loginWithPassword(email, pass, function(err) { 43 | if (err) { 44 | self.setState({loginErrMsg: err.reason}); 45 | self.props.onLoginError(err); 46 | self.dbug("ERROR", err.reason); 47 | } else { 48 | console.log("Success", Meteor.user()); 49 | } 50 | }); 51 | }, 52 | 53 | render: function() { 54 | var formProps = { 55 | className: this.props.formClassName, 56 | noValidate: this.props.noValidate, 57 | onSubmit: this.handleSubmit 58 | }; 59 | 60 | return ( 61 | React.createElement("form", formProps, 62 | React.createElement("input", {ref: "email", type: "email"}), 63 | React.createElement("input", {ref: "password", type: "password"}), 64 | React.createElement("input", {ref: "submit", type: "submit"}), 65 | React.createElement("div", {ref: "errMsg"}, this.state.loginErrMsg) 66 | ) 67 | ); 68 | } 69 | }); 70 | --------------------------------------------------------------------------------