N
N
naneri2014-10-09 13:02:08
Laravel
naneri, 2014-10-09 13:02:08

Where should the custom Authoriazation class be placed in Laravel?

I decided to make additional functionality for my project and it turns out that it is much easier to connect another application written in Laravel to this database than to finish the original one.
Now a small stupor with authorization. I roughly figured out how to check the username and password from the inputs, but in principle it is useless. I need to write a class that will be responsible for authorization and will replace the native one from Laravel, because some methods of this class are not quite suitable for Laravel (and the rest are simply not needed).
I found some good tutorials:
1
2
But I can't figure out where this class should be placed in the application.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vyacheslav Plisko, 2014-10-09
@AmdY

It is best to put everything in your directories, for this add an auto-launching rule and namespace to composer.json, for example, for \Acme\*

"autoload": {
    "psr-4": {
      "Acme\\": "/path/to/lib/"
    },
    "classmap": [
      "app/controllers",
      "app/database/migrations",
      "app/database/seeds",
      "tests/TestCase.php"
    ]
}

and don't forget to do composer dump-autoload

E
Evgeny Elchev, 2015-08-06
@rsi

I understand your question, but not completely, where exactly is your plug? In principle, laravel.com itself has a good description of authorization.
I understand that you do not quite understand the architecture of Laravel? Because you are most likely editing the controller, so it should be in the controllers folder. In fact, I finished it, native authorization in Laravel out of the box works on traits (I advise you to read what a trait is in php) and they mix functionality into the controller, you just need to override the authorization method, in fact in the auth controller you need to implement your own method that will override the method from trait.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question