
いつもお世話になります。
標記の件ですが、下記サイトを参考にコーディングしてみました。
Laravelの認証機能でユーザ情報の論理削除(ソフトデリート)を実装する
・・・が、ソフトデリートしたユーザのメールアドレス、パスワードを
ログイン画面で入力するとログインできてしまいます。
そもそも論でお聞きしたいのですが、ソフトデリートしたユーザであっても
ログイン可能なのは仕様なのでしょうか?
ちなみに環境は以下の通りです。
Laravel 5.5
PHP 7.2.7
MySQL 5.7.22
以上、よろしくお願い致します。
※以下、コーディングした内容です。
マイグレーションファイルの作成、マイグレートの実行
$ php artisan make:migration add_column_softDeletes_users_table --table=users
$ view 2018_07_12_045301_add_column_soft_deletes_users_table.php
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class AddColumnSoftDeletesUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('users', function (Blueprint $table) { $table->softDeletes(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('users', function (Blueprint $table) { $table->dropColumn('deleted_at'); }); } }
モデルの作成
$ php artisan make:model Models/Users
$ view Users.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; class Users extends Model { use SoftDeletes; protected $table = 'users'; protected $dates = ['deleted_at']; }
下記SQL文にて、ユーザをソフトデリートしました。
update users set deleted_at = '2018-07-12 01:03:26' where id = 1;
前項でソフトデリートしたユーザでログインを試みるとログインできてしまいます。



回答2件
あなたの回答
tips
プレビュー