Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
Release Version 0.2.0 version bump updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Retterer committed Jan 28, 2016
2 parents 3ae4e52 + 449a363 commit bb429ce
Show file tree
Hide file tree
Showing 34 changed files with 1,383 additions and 21 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ Change Log

All library changes, in descending order.

Version 0.2.0
-------------

**Released on January 6, 2016.**

- Added Events (thanks @Kryten0807)
- Added ability to create custom data during registration (thanks @Kryten0807) (Fixes #25)
- Update Documentation
- Fixed #28 to allow refreshing access_token
- Added tests for ID Site (Fixes #29)

Version 0.1.0
-------------

Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ Follow these steps to add Stormpath user authentication to your Laravel app.
```

5. **Install The Package**


Open your composer.json file and add the following to your require block:

```bash
$ composer require stormpath/laravel
"stormpath/laravel": "0.*"
```

6. **Include It In Your App**
Expand All @@ -50,7 +52,7 @@ Follow these steps to add Stormpath user authentication to your Laravel app.
7. **Configure It**

To modify the configuration of the package, you will need to publish the config file. Run the following in your terminal:

```bash
$ php artisan vendor:publish
```
Expand All @@ -64,12 +66,12 @@ Follow these steps to add Stormpath user authentication to your Laravel app.
```

If the user tries to access this route without being logged in, they will be redirected to the login page.

If you want to make sure ONLY guests can use the route, You can use `stormpath.guest` as a middleware:
```php
Route::get('/page', ['middleware'=>'stormpath.guest']);
```

If the user tries to access this route while logged in, they will be redirected to the home page.

9. **Login**
Expand Down Expand Up @@ -118,4 +120,4 @@ Copyright © 2013-2015 Stormpath, Inc. and contributors.
This project is open-source via the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).


[documentation]: https://docs.stormpath.com/php/laravel/latest/
[documentation]: https://docs.stormpath.com/php/laravel/latest/
8 changes: 8 additions & 0 deletions docs/contributors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ Brian has contributed to the core of this package.

- Github: https://github.com/bretterer

Kryten0807
**********

Kryten0807 allowed for the use of events in the integration.
Also added in Custom Data Capabilities to the Registration.

- Github: https://github.com/Kryten0807



.. _Stormpath: https://stormpath.com/
Expand Down
142 changes: 142 additions & 0 deletions docs/events.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
.. _events:


Laravel Events
==============

This package provides a number of `events`_ allowing you to respond to user
actions as they happen.


Available Events
----------------

The following events (and their corresponding classes) are triggered during
Stormpath operations:

+-----------------------------------+------------------------------------------------------+
| Class | Description |
+===================================+======================================================+
| ``UserIsRegistering`` | A potential new user has completed the registration |
| (cancellable) | form and submitted it. The form data has passed |
| | validation. |
+-----------------------------------+------------------------------------------------------+
| ``UserHasRegistered`` | A new user has registered. |
+-----------------------------------+------------------------------------------------------+
| ``UserIsLoggingIn`` | A user has completed the login form and submitted it.|
| (cancellable) | The form data has passed the initial validation, but |
| | the user has not been authenticated yet. |
+-----------------------------------+------------------------------------------------------+
| ``UserHasLoggedIn`` | A user has successfully logged in. |
+-----------------------------------+------------------------------------------------------+
| ``UserIsLoggingOut`` | A user has visited the ``logout`` URL but has not |
| (cancellable) | been logged out yet. |
+-----------------------------------+------------------------------------------------------+
| ``UserHasLoggedOut`` | A user has successfully logged out. |
+-----------------------------------+------------------------------------------------------+
| ``UserHasRequestedPasswordReset`` | A user has completed the password reset form and the |
| | password reset email has been sent. |
+-----------------------------------+------------------------------------------------------+
| ``UserHasResetPassword`` | A user has successfully reset their password. |
+-----------------------------------+------------------------------------------------------+

Note that all of the class names above are in the ``Stormpath\Laravel\Events``
namespace.


Listening for Events
--------------------

To register your listeners for these events, follow the
`Laravel documentation for Registering Events`_. For example, to register a
listener for the "registered" event, add the following to your
``EventServiceProvider``::

protected $listen = [
'Stormpath\Laravel\Events\UserHasRegistered' => [
'App\Listeners\HandleNewUserRegistration',
],
];

where ``App\Listeners\HandleNewUserRegistration`` is a class in your application
which handles the event when it is fired. The listener class is defined
according to the `Laravel documentation on defining listeners`_.


Terminating Event Actions
-------------------------

There may be times when it is necessary to halt processing based on some
processing you are doing in your listener. To do this, simply return ``false``
from the ``handle`` method of your listener. Note that this will only have an
effect for the events that are marked as "cancellable" in the table above.

For example, maybe you want to prevent a user from registering if their first
name is "Bob". Your handler should look like this::

public function handle(UserIsRegistering $event)
{
// get the form data that the user has submitted
//
$data = $event->getData();

// check the givenName field
//
if ($data['givenName']=='Bob') {
return false;
}

// the name is not Bob, so just carry on...
}

This will abort the registration request. When this is done, a
``Stormpath\Laravel\Exceptions\ActionAbortedException`` will be thrown. In the
example above, you might catch that exception & redirect the user to a page that
says "No Bobs Allowed!"


Event Class Parameters
----------------------

Most of the event classes include data related to the event occurring. The
important data is retrieved via an accessor function.

+-----------------------------------+----------------+------------------------------------------------------+
| Class | Accessor | Description |
+===================================+================+======================================================+
| ``UserIsRegistering`` | ``getData`` | ``array`` - The form data entered by the user |
+-----------------------------------+----------------+------------------------------------------------------+
| ``UserHasRegistered`` | ``getAccount`` | ``Stormpath\Resource\Account`` - The account object |
| | | for the newly-registered user |
+-----------------------------------+----------------+------------------------------------------------------+
| ``UserIsLoggingIn`` | ``getData`` | ``array`` - The form data entered by the user |
+-----------------------------------+----------------+------------------------------------------------------+
| ``UserHasLoggedIn`` | ``getAccount`` | ``Stormpath\Resource\Account`` - The account object |
| | | for the user who has just logged in |
+-----------------------------------+----------------+------------------------------------------------------+
| ``UserIsLoggingOut`` | n/a | No parameters |
+-----------------------------------+----------------+------------------------------------------------------+
| ``UserHasLoggedOut`` | n/a | No parameters |
+-----------------------------------+----------------+------------------------------------------------------+
| ``UserHasRequestedPasswordReset`` | ``getData`` | ``array`` - The form data entered by the user |
+-----------------------------------+----------------+------------------------------------------------------+
| ``UserHasResetPassword`` | n/a | No parameters |
+-----------------------------------+----------------+------------------------------------------------------+

So, for example, if you want to do something with a user who has just logged
out, the handler might look like this::

public function handle(UserHasLoggedOut $event)
{
// get the user account
//
$user = $event->getAccount();

// do something with the user...
}



.. _events: https://laravel.com/docs/5.2/events
.. _Laravel documentation for Registering Events: https://laravel.com/docs/5.2/events#registering-events-and-listeners
.. _Laravel documentation on defining listeners: https://laravel.com/docs/5.2/events#defining-listeners
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ user, start here!
login
logout
password_reset
events
help
contributors

Expand Down Expand Up @@ -59,4 +60,3 @@ limitations under the License.
.. _GitHub Repository: http://github.com/stormpath/stormpath-laravel
.. _develop: http://github.com/stormpath/stormpath-laravel/tree/develop
.. _Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0.html

21 changes: 18 additions & 3 deletions docs/registration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,23 @@ required by the user:

While email and password will always be required, you do not need to require
givenName and surname. These can be configured as optional fields, or omitted
entirely. You can also specify your own custom fields. We'll cover each use
case in detail.
entirely. We'll cover each use case in detail.

You can also specify your own custom fields. In this case, the custom data will
be saved with the account and will be accessible via the ``customData`` property
of the account. To add your own fields, add the following to the register config
section for each one of the fields you would like to add:

.. code-block:: php
'stormpath.web.register.form.fields.customData1' => [
'enabled' => true,
'name' => 'customData1',
'placeholder' => 'customData1',
'required' => true,
'type' => 'text',
]
Password Strength Rules
-----------------------
Expand Down Expand Up @@ -110,4 +125,4 @@ By default the nextUri is to the `/` page, but you can modify this.


.. _Stormpath Admin Console: https://api.stormpath.com
.. _Account Password Strength Policy: https://docs.stormpath.com/rest/product-guide/#account-password-strength-policy
.. _Account Password Strength Policy: https://docs.stormpath.com/rest/product-guide/#account-password-strength-policy
Empty file added src/Events/.gitkeep
Empty file.
35 changes: 35 additions & 0 deletions src/Events/UserHasLoggedIn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Stormpath\Laravel\Events;

use Stormpath\Resource\Account;

class UserHasLoggedIn
{
/**
* The account property
*
* @var Account
*/
private $account = null;

/**
* Create a new event instance.
*
* @param array $data The form data from the log in request
*/
public function __construct(Account $account)
{
$this->account = $account;
}

/**
* Get the account associated with this event
*
* @return Account The account associated with this event
*/
public function getAccount()
{
return $this->account;
}
}
35 changes: 35 additions & 0 deletions src/Events/UserHasRegistered.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Stormpath\Laravel\Events;

use Stormpath\Resource\Account;

class UserHasRegistered
{
/**
* The account property
*
* @var Account
*/
private $account = null;

/**
* Create a new event instance.
*
* @param array $data The form data from the registration request
*/
public function __construct(Account $account)
{
$this->account = $account;
}

/**
* Get the account associated with this event
*
* @return Account The account associated with this event
*/
public function getAccount()
{
return $this->account;
}
}
34 changes: 34 additions & 0 deletions src/Events/UserHasRequestedPasswordReset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Stormpath\Laravel\Events;


class UserHasRequestedPasswordReset
{
/**
* The form data
*
* @var array
*/
private $data = null;

/**
* Create a new event instance.
*
* @param array $data The form data from the registration request
*/
public function __construct(array $data)
{
$this->data = $data;
}

/**
* Get the form data provided with this event
*
* @return array The form data
*/
public function getData()
{
return $this->data;
}
}
16 changes: 16 additions & 0 deletions src/Events/UserHasResetPassword.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Stormpath\Laravel\Events;


class UserHasResetPassword
{
/**
* Create a new event instance.
*
* @param array $data The form data from the registration request
*/
public function __construct()
{
}
}
Loading

0 comments on commit bb429ce

Please sign in to comment.