From a3353c1b4335d35d8433bd8489259ae632bcf073 Mon Sep 17 00:00:00 2001 From: Luka Skukan Date: Tue, 14 Feb 2017 16:11:50 +0100 Subject: [PATCH 1/2] Make autologin opt-in behaviour on register --- src/components/RegistrationForm.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/RegistrationForm.js b/src/components/RegistrationForm.js index 524831b..4719de3 100644 --- a/src/components/RegistrationForm.js +++ b/src/components/RegistrationForm.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {PropTypes} from 'react'; import { Link } from 'react-router'; import utils from '../utils'; @@ -174,6 +174,17 @@ export default class RegistrationForm extends React.Component { router: React.PropTypes.object.isRequired }; + static propTypes = { + autoLogin: PropTypes.bool, + onSubmitSuccess: PropTypes.func, + onSubmitError: PropTypes.func, + onSubmit: PropTypes.func, + }; + + static defaultProps = { + autoLogin: false + }; + state = { fields: { givenName: '', @@ -230,7 +241,7 @@ export default class RegistrationForm extends React.Component { } setErrorState(err); - } else if (result.status === 'ENABLED') { + } else if (result.status === 'ENABLED' && this.props.autoLogin) { UserActions.login({ login: data.email || data.username, password: data.password @@ -376,7 +387,7 @@ export default class RegistrationForm extends React.Component { render() { if (this.props.children) { - var selectedProps = utils.excludeProps(['redirectTo', 'hideSocial', 'onSubmit', 'onSubmitError', 'onSubmitSuccess', 'children'], this.props); + var selectedProps = utils.excludeProps(['autoLogin', 'redirectTo', 'hideSocial', 'onSubmit', 'onSubmitError', 'onSubmitSuccess', 'children'], this.props); return (
From 9df7e10bba76e22cb95b710f233bb69448e1aa7f Mon Sep 17 00:00:00 2001 From: Luka Skukan Date: Tue, 14 Feb 2017 16:11:58 +0100 Subject: [PATCH 2/2] Document autoLogin --- docs/api.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index a93a01d..a4d896a 100644 --- a/docs/api.md +++ b/docs/api.md @@ -349,7 +349,19 @@ Specify `hideSocial` to hide the ability to register with a social provider. ``` -Customize the form by providing your own markup. +Specify `autoLogin` to automatically login the user after registration. + +```html + +``` + +or just + +```html + +``` + +Customize the form by providing your own markup. By default, the registration form will render these four fields, and they will be required by the user: `givenName`, `surname`, `email`, and `password`. Express.js users who want to make `givenName` and/or `surname` optional, or to add new required fields (like `username`), can refer to [Stormpath Express Library Guide](https://docs.stormpath.com/nodejs/express/latest/registration.html).