stormpath / stormpath-laravel

Build simple, secure web applications with Stormpath and Laravel
Other
29 stars 6 forks source link

Feature Request: Events #24

Closed kryten87 closed 8 years ago

kryten87 commented 8 years ago

I think this library would benefit from including a set of Laravel events. This would allow us to extend the functionality without hacking.

For example: imagine that I have an access control layer and I want to set up some default values for a new user.

As things stand now, it appears I need to extend the RegisterController to include my functionality and override the register routes in routes.php to ensure my controller is called - unless there's a simpler and less hacky way of doing it that I've missed (please let me know!).

With an Event, I could create a listener class and subscribe to a standard stormpath.onregister event. My listener would receive an instance of the newly-registered Stormpath\Resource\Account object and then I could append my values & save the object.

bretterer commented 8 years ago

@Kryten0807 This is a great idea and I will add it to our list of features.

We of course are always open to Pull Requests of any of the Stormpath Libraries and welcome this kind of input.

-Brian

kryten87 commented 8 years ago

Thanks. I did fork the repo & try extending it, but most of the existing tests failed. The error I got was Stormpath\Resource\ResourceError: Oops! We encountered an unexpected error. Please contact support and explain what you were doing at the time this error occurred.

I suspect I have something configured incorrectly - it appears that the tests are hitting the Stormpath server. If you have any ideas what the problem is, please let me know!

EDIT: after some digging into the source, I found that the API is returning a developer message with the error: "Reserved application limit reached. Please add more applications in the admin console.". After some more digging through the documentation, I discovered that you need to add more applications by going into the developer console, selecting "Subscription" from the dropdown menu in the upper right, then changing the number of available applications on the far left. I'm going to add this info the readme when I make my pull request.

bretterer commented 8 years ago

@Kryten0807 Yes, that is one of the things to check here. I usually have my applications set to 10, and you are able to do this on the developer plan.

There are a couple environment variables that need to be set in order for tests to work..

STORMPATH_SDK_TEST_API_KEY_FILE_LOCATION=/path/to/apiKey.properties STORMPATH_CLIENT_APIKEY_ID={{apikey.id}} STORMPATH_CLIENT_APIKEY_SECRET={apikey.secret

bretterer commented 8 years ago

This has been merged into develop and will be put in the next release.