Skip to content

Commit

Permalink
Merge 1.0 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewis-everley committed Apr 28, 2018
2 parents 58f38a8 + 27ddc38 commit 4c9a8b6
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 129 deletions.
4 changes: 4 additions & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ SilverStripe\Security\Group:
extensions:
- ilateral\SilverStripe\Users\Extensions\GroupExtension
SilverStripe\Security\Member:
required_fields:
- "FirstName"
- "Surname"
- "Email"
extensions:
- ilateral\SilverStripe\Users\Extensions\MemberExtension
SilverStripe\Control\Controller:
Expand Down
12 changes: 11 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ Minor update to:

* Add additional extension hooks when edit form submitted

# 1.3.0

* Switch to using frontend form fields to generate the "Edit Account Details" form
* Add better error handling on edit account submission

# 2.0.0

* SS4 support based on version 1.1.1
Expand All @@ -47,4 +52,9 @@ Minor update to:

# 2.0.1

* Add additional extension hooks when edit form submitted
* Add additional extension hooks when edit form submitted

# 2.1.0

* Switch to using frontend form fields to generate the "Edit Account Details" form
* Add better error handling on edit account submission
37 changes: 36 additions & 1 deletion docs/en/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,39 @@ This module makes `$UserAccountNav` available to all your
controllers. You can include this variable in your templates and it
will add an account navigation menu.

If you wish to change the styling of this menu, simply edit the `Users_AccountNav.ss` template include.
If you wish to change the styling of this menu, simply edit the `Users_AccountNav.ss`
template include.

## Adding/Removing fields to the Edit Account form

By default, this module generates an "Edit your account" view via:

http://yoursite.com/users/account

This view uses an instance of `Users_EditAccountForm` to generate the edit form.

`Users_EditAccountForm` uses `Member::getFrontEndFields()` to generate the fieldlist,
it also uses the `Member.hidden_fields` config variable, as well as it's own
`ignore_member_fields` config variable, to remove fields from the EditForm.

If you want to remove additional fields from this form (for example `Locale`), you can
add the following to your config.yml:

```yml
Users_EditAccountForm:
ignore_member_fields:
- "Locale"
```
### Updating Required Fields
This module uses `Member.required_fields` config variable to determine required fields.
If you added the Field `PhoneNumber` and wanted to make it required, you could do as below:

```yml
Member:
db:
- "PhoneNumber"
required_fields:
- "PhoneNumber"
```
1 change: 1 addition & 0 deletions lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ en:
DETAILSUPDATED: 'Account details updated'
EDITDETAILS: 'Edit account details'
EditAccountDetails: 'Edit account details'
FirstRegistered: 'First Registered'
HELLO: Hi
LOGIN: 'Log in'
LOGOUT: Logout
Expand Down
82 changes: 31 additions & 51 deletions src/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* config, but will probably be extended in future to provide additional
* functionality.
*
* @author i-lateral (http://www.i-lateral.com)
* @package users
* @package Users
* @author i-lateral <[email protected]>
*/
class Users
{
Expand All @@ -21,36 +21,36 @@ class Users
/**
* Minimum character length of the password required
* on registration/account editing
*
* @var int
*
* @var int
* @config
*/
private static $password_min_length = 6;
*/
private static $password_min_length = 6;

/**
* Maximum character length of the password required
/**
* Maximum character length of the password required
* on registration/account editing
*
* @var int
*
* @var int
* @config
*/
private static $password_max_length = 16;
*/
private static $password_max_length = 16;

/**
* Enforces strong password (at least one digit and one alphanumeric
* character) on registration/account editing
*
* @var boolean
/**
* Enforces strong password (at least one digit and one alphanumeric
* character) on registration/account editing
*
* @var boolean
* @config
*/
private static $password_require_strong = false;
*/
private static $password_require_strong = false;

/**
* Stipulate if a user requires verification. NOTE this does not
* actually deny the user the ability to login, it only alerts them
* that they need validiation
*
* @var boolean
* @var boolean
* @config
*/
private static $require_verification = true;
Expand All @@ -59,7 +59,7 @@ class Users
* Stipulate whether to send a verification email to users after
* registration
*
* @var boolean
* @var boolean
* @config
*/
private static $send_verification_email = false;
Expand All @@ -68,15 +68,15 @@ class Users
* Stipulate the sender address for emails sent from this module. If
* not set, use the default @Email.admin_email instead.
*
* @var string
* @var string
* @config
*/
private static $send_email_from;

/**
* Auto login users after registration
*
* @var boolean
* @var boolean
* @config
*/
private static $login_after_register = true;
Expand All @@ -85,30 +85,20 @@ class Users
* Add new users to the following groups. This is a list of group codes.
* Adding a new code will add the user to this group
*
* @var array
* @var array
* @config
*/
private static $new_user_groups = [
"users-frontend"
];

/**
* Add a group to the list of groups a new user is added to on
* registering.
*
* @param string Group code that will be used
*/
public static function addNewUserGroup($code)
{
Deprecation::notice("1.3", "addNewUserGroup depreciated, use global config instead");
self::config()->new_user_groups[] = $code;
}

/**
* Remove a group from the list of groups a new user is added to on
* registering.
*
* @param string Group code that will be used
* @param string $code Group code that will be used
*
* @return void
*/
public static function removeNewUserGroup($code)
{
Expand All @@ -121,30 +111,20 @@ public static function removeNewUserGroup($code)
* Groups a user will be added to when verified. This should be an
* array of group "codes", NOT names or ID's
*
* @var array
* @var array
* @config
*/
private static $verification_groups = [
"users-verified"
];

/**
* Add a group toextends Object the list of groups a new user is added to on
* registering.
*
* @param string Group code that will be used
*/
public static function addVerificationGroup($code)
{
Deprecation::notice("1.3", "addVerificationGroup depreciated, use global config instead");
self::config()->verification_groups[] = $code;
}

/**
* Remove a group from the list of groups a new user is added to on
* registering.
*
* @param string Group code that will be used
* @param string $code Group code that will be used
*
* @return void
*/
public static function removeVerificationGroup($code)
{
Expand Down
Loading

0 comments on commit 4c9a8b6

Please sign in to comment.