| 1 | <?php |
||
| 9 | class ServiceProvider extends EventServiceProvider |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Bootstrap the application services. |
||
| 13 | * |
||
| 14 | * @return void |
||
| 15 | */ |
||
| 16 | public function boot() |
||
| 17 | { |
||
| 18 | parent::boot(); |
||
| 19 | |||
| 20 | // W starej wersji 4programmers.net hasla byly hashowane przy pomocy sha256 + sol. Jezeli w bazie |
||
| 21 | // danych jest stary hash, to zmieniamy hasha i zapisujemy do bazy danych |
||
| 22 | $this->app['events']->listen(Attempting::class, function (Attempting $attempting) { |
||
| 23 | $user = User::where('name', $attempting->credentials['name'])->first(); |
||
| 24 | |||
| 25 | if ($user && $user->salt |
||
| 26 | && $user->password === hash('sha256', $user->salt . $attempting->credentials['password'])) { |
||
| 27 | $user->password = bcrypt($attempting->credentials['password']); |
||
| 28 | $user->salt = null; |
||
| 29 | $user->save(); |
||
| 30 | } |
||
| 31 | }); |
||
| 32 | } |
||
| 33 | } |
||
| 34 |