Giter Site home page Giter Site logo

rainlab-user-api's People

Contributors

scottbedard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rainlab-user-api's Issues

Improve mail assertions

Leaving this here as a reminder to future me, mail assertions can be cleaned up by using Alxy's mail fake.

https://gist.github.com/alxy/6e74d306be7bd0c9d1f134f34d547a44

Example usage:

public function testNewFakeMailer()
{
    Mail::swap(new MailFake());

    // These variables are available inside the message as Twig
    $vars = ['name' => 'Joe', 'user' => 'Mary'];

    Mail::send('backend::mail.invite', $vars, function($message) {
        $message->to('[email protected]', 'Admin Person');
        $message->subject('This is a reminder');
    });

    Mail::assertSent('backend::mail.invite', function (Mailable $mailable) use ($vars) {
        return $mailable->viewData['name'] === 'Joe' &&
            $mailable->viewData['user'] === 'Mary' &&
            $mailable->hasTo('[email protected]');
    });
}

auto activation is broken

Steps to reproduce

  1. Set activation mode to auto
  2. Create a user

Expected result

The user should be auto activated.

Actual result

The user is not activated.

1.0 announcement

The next releases will contain a breaking change to all endpoints, and will begin the official versioning of this plugin.

What's being changed

We are no longer going to catch our own exceptions.

In hind sight, this was never the best way to do things. Every application is going to need to handle errors for their own endpoints. Having our plugin catch its own errors forces the consuming applications to pick from the following options, both of which are pretty unappetizing.

  • They can adopt our exception handling strategy for consistency, giving up the ability to handle their own errors how they like.

  • Or they can have multiple error handling strategies. This is probably the worse of the two options, as now they would need to remember which endpoints respond which ways.

Going forward

Applications should use October's default error responses. Uncaught exceptions already have explicit status codes and store necessary meta data in the headers.

As an added benefit we are opting into October's default error formatting, giving us nice stack traces in development.

Existing applications that wish to continue handling the exceptions as we previously did must now catch the exceptions themselves. As an example, adding this to your boot.php file would catch all of our validation errors.

App::error(function(ValidationException $err) {
    return [
        // ...
    ];
});

Settings models don't fire model.getAttribute events

Settings models do not fire model.getAttribute events when the static get method is called. Because of this, plugins are unable to define user configuration by listening for that event. For example, this would have no effect on the API.

UserSettings::extend(function($model) {
  $model->bindEvent('model.getAttribute', function($attribute) {
    if ($attribute === 'login_attribute') {
      return UserSettings::LOGIN_USERNAME;
    }
  });
});

To side-step this issue, we should be able to use an instance of the settings model rather than the get method.

// before
UserSettings::get('login_attribute', $default);

// after
UserSettings::instance()->login_attribute ?: $default;

Why don't you share on the marketplace? Is it possible to disallow some routes?

Hi Scott,

I've found this repo which could be helpful in a project I'm currently working on where I need to share an auth session between a Laravel app and an OctoberCMS installation.

I've looked on the marketplace and didn't find it there so I'm asking why? Does it contain some kind of issue or that kind of stuff? Maybe I can help.

Also a little question: is it possible to disallow some routes? Basically I just want to be open the login/logout routes. I know I can prevent users to access it by creating a custom routes.php with the same routes and require it before you're but if it's directly possible in your package, it's nice!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.