mirror of
https://github.com/vale981/accounts-ui
synced 2025-03-05 09:51:40 -05:00
Bugfixes for the hooks.
This commit is contained in:
parent
c46bc02d8b
commit
b787bfeeb2
7 changed files with 21 additions and 22 deletions
|
@ -1,5 +1,9 @@
|
|||
# ChangeLog
|
||||
|
||||
### v1.1.1
|
||||
|
||||
* Bugfixes
|
||||
|
||||
### v1.1.0
|
||||
|
||||
* Renamed package to std:accounts-ui
|
||||
|
|
12
README.md
12
README.md
|
@ -1,6 +1,6 @@
|
|||
# React Accounts UI
|
||||
|
||||
Current version 1.1.0
|
||||
Current version 1.1.1
|
||||
|
||||
## Features
|
||||
|
||||
|
@ -58,19 +58,19 @@ Configure the behavior of `<Accounts.ui.LoginForm />`
|
|||
* **homeRoutePath** String
|
||||
Set the path to where you would like the user to be redirected after a successful login or sign out.
|
||||
|
||||
* **onSubmitHook** function(error, state)
|
||||
* **onSubmitHook** function(error, state) **client**
|
||||
Called when the LoginForm is being submitted: allows for custom actions to be taken on form submission. error contains possible errors occurred during the submission process, state specifies the LoginForm internal state from which the submission was triggered. A nice use case might be closing the modal or side-menu or dropdown showing LoginForm.
|
||||
|
||||
* **preSignUpHook** function(options)
|
||||
* **onPreSignUpHook** function(options) **client**
|
||||
Called just before submitting the LoginForm for sign-up: allows for custom actions on the data being submitted. A nice use could be extending the user profile object accessing options.profile. to be taken on form submission. The plain text password is also provided for any reasonable use. If you return a promise, the submission will wait until you resolve it.
|
||||
|
||||
* **postSignUpHook** func(userId, info) **server**
|
||||
* **onPostSignUpHook** func(userId, info) **server**
|
||||
Called server side, just after a successful user account creation, post submitting the pwdForm for sign-up: allows for custom actions on the data being submitted after we are sure a new user was successfully created. A common use might be applying roles to the user, as this is only possible after fully completing user creation in `alanning:roles`. The userId is available as the first parameter, so that user user object may be retrieved.
|
||||
|
||||
* **postSignUpHook** func(userId, info) **client**
|
||||
* **onPostSignUpHook** func(userId, info) **client**
|
||||
Called client side, just after a successful user account creation, post submitting the pwdForm for sign-up: allows for custom actions on the data being submitted after we are sure a new user was successfully created. Default is **loginPath**.
|
||||
|
||||
* **resetPasswordHook** function()
|
||||
* **onResetPasswordHook** function()
|
||||
Change the default redirect behavior when the user clicks the link to reset their email sent from the system, i.e. you want a custom path for the reset password form. Default is **loginPath**.
|
||||
|
||||
* **onEnrollAccountHook** function()
|
||||
|
|
|
@ -13,6 +13,7 @@ Accounts.ui._options = {
|
|||
requestOfflineToken: {},
|
||||
forceApprovalPrompt: {},
|
||||
passwordSignupFields: 'NO_PASSWORD',
|
||||
minimumPasswordLength: 6,
|
||||
loginPath: '/',
|
||||
signUpPath: null,
|
||||
resetPasswordPath: null,
|
||||
|
|
|
@ -44,9 +44,10 @@ export function passwordSignupFields() {
|
|||
};
|
||||
|
||||
export function validatePassword(password){
|
||||
if (password.length >= 7) {
|
||||
if (password.length >= Accounts.ui._options.minimumPasswordLength) {
|
||||
return true;
|
||||
} else {
|
||||
this.showMessage(T9n.get("error.minChar").replace(/7/, Accounts.ui._options.minimumPasswordLength), 'warning');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,23 +2,19 @@ import React from 'react';
|
|||
import { Accounts } from 'meteor/accounts-base';
|
||||
|
||||
export class Button extends React.Component {
|
||||
handleClick(evt) {
|
||||
let { onClick, href } = this.props;
|
||||
if (!href) {
|
||||
evt.preventDefault();
|
||||
onClick(evt);
|
||||
}
|
||||
shouldComponentUpdate(nextProps) {
|
||||
return this.props.href == nextProps.href;
|
||||
}
|
||||
|
||||
render () {
|
||||
const { label, href = null, type, disabled = false, className } = this.props;
|
||||
const { label, href = null, type, disabled = false, className, onClick } = this.props;
|
||||
return type == 'link' ? (
|
||||
<a href={ href } className={ className } onClick={ this.handleClick.bind(this) }>{ label }</a>
|
||||
<a href={ href } className={ className } onClick={ onClick }>{ label }</a>
|
||||
) : (
|
||||
<button className={ className }
|
||||
type={type}
|
||||
disabled={ disabled }
|
||||
onClick={ this.handleClick.bind(this) }>{ label }</button>
|
||||
onClick={ onClick }>{ label }</button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -363,7 +363,7 @@ export class LoginForm extends Tracker.Component {
|
|||
|
||||
showForgotPasswordLink() {
|
||||
return !this.state.user
|
||||
&& this.state.formState != STATES.PASSWORD_RESET
|
||||
&& this.state.formState == STATES.SIGN_IN
|
||||
&& _.contains(
|
||||
["USERNAME_AND_EMAIL", "USERNAME_AND_OPTIONAL_EMAIL", "EMAIL_ONLY"],
|
||||
passwordSignupFields());
|
||||
|
@ -543,7 +543,6 @@ export class LoginForm extends Tracker.Component {
|
|||
options.password = Meteor.uuid();
|
||||
}
|
||||
else if (!validatePassword(password)) {
|
||||
this.showMessage(T9n.get("error.minChar"), 'warning');
|
||||
Accounts.ui._options.onSubmitHook("error.minChar", formState);
|
||||
return;
|
||||
}
|
||||
|
@ -578,7 +577,7 @@ export class LoginForm extends Tracker.Component {
|
|||
};
|
||||
|
||||
// Allow for Promises to return.
|
||||
let promise = Accounts.ui._options.preSignUpHook(options);
|
||||
let promise = Accounts.ui._options.onPreSignUpHook(options);
|
||||
if (promise instanceof Promise) {
|
||||
promise.then(SignUp);
|
||||
}
|
||||
|
@ -672,8 +671,6 @@ export class LoginForm extends Tracker.Component {
|
|||
} = this.state;
|
||||
|
||||
if ( !validatePassword(newPassword) ){
|
||||
this.showMessage(T9n.get("error.minChar"), 'warning');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Package.describe({
|
||||
name: 'std:accounts-ui',
|
||||
version: '1.1.0',
|
||||
version: '1.1.1',
|
||||
summary: 'Accounts UI for React in Meteor 1.3',
|
||||
git: 'https://github.com/studiointeract/accounts-ui',
|
||||
documentation: 'README.md'
|
||||
|
|
Loading…
Add table
Reference in a new issue