Php 删除哨兵帐户激活检查
我有一个名为“users”的表,Sentry正在使用它,但是我删除了不需要的列,如激活码和持久化码等 这是我的表的结构: 我试图使用我通过“Sentry::createUser()”创建的帐户登录,但是“UserNotActivatedException”一直被抛出,阻止我登录 这是我的登录代码:Php 删除哨兵帐户激活检查,php,mysql,laravel,authentication,cartalyst-sentry,Php,Mysql,Laravel,Authentication,Cartalyst Sentry,我有一个名为“users”的表,Sentry正在使用它,但是我删除了不需要的列,如激活码和持久化码等 这是我的表的结构: 我试图使用我通过“Sentry::createUser()”创建的帐户登录,但是“UserNotActivatedException”一直被抛出,阻止我登录 这是我的登录代码: public function postLogin() { #Build login if(!Input::has('email') || !Input::has('password
public function postLogin() {
#Build login
if(!Input::has('email') || !Input::has('password')) {
return Response::json(['response' => 'Please enter an email address and a password!']);
}
try {
$credentials = [
'email' => Input::get('email'),
'password' => Input::get('password')
];
$user = Sentry::authenticate($credentials, false);
return Response::json(['response' => 'You have been logged in.']);
} catch(Cartalyst\Sentry\Users\LoginRequiredException $e) {
return Response::json(['response' => 'Please enter an email address!']);
} catch(Cartalyst\Sentry\Users\PasswordRequiredException $e) {
return Response::json(['response' => 'Please enter a password!']);
} catch(Cartalyst\Sentry\Users\WrongPasswordException $e) {
return Response::json(['response' => 'That account could not be found1!']);
} catch(Cartalyst\Sentry\Users\UserNotFoundException $e) {
return Response::json(['response' => 'That account could not be found2!']);
} catch(Cartalyst\Sentry\Users\UserNotActivatedException $e) {
return Response::json(['response' => 'That account could not be found3!']);
} catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
return Response::json(['response' => 'That account could has been suspended!']);
} catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
return Response::json(['response' => 'That account has been banned!']);
}
}
这是正在返回的响应:
有没有办法禁用Sentry中用户的激活检查?我已经通过创建自己的用户类并将$activated变量设置为true修复了错误。 用户类别:
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
use Cartalyst\Sentry\Users\Eloquent\User as SentryUserModel;
class User extends SentryUserModel implements UserInterface, RemindableInterface {
public $activated = true;
public function getAuthIdentifier() {
return $this->getKey();
}
public function getAuthPassword() {
return $this->password;
}
public function getRememberToken() {
return $this->remember_token;
}
public function setRememberToken($value) {
$this->remember_token = $value;
}
public function getRememberTokenName() {
return 'remember_token';
}
public function getReminderEmail() {
return $this->email;
}
}
我还创建了两个新迁移,将“persist\u code”和“last\u login”列添加到我的表中:
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddLastLoginToUsersTable extends Migration {
public function up() {
Schema::table('users', function(Blueprint $table) {
$table->string('last_login')->nullable();
});
}
public function down() {
Schema::table('users', function(Blueprint $table) {
$table->dropColumn('last_login');
});
}
}
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddPersistCodeToUsersTable extends Migration {
public function up() {
Schema::table('users', function(Blueprint $table) {
$table->string('persist_code')->nullable();
});
}
public function down() {
Schema::table('users', function(Blueprint $table) {
$table->dropColumn('persist_code');
});
}
}
我没有试过,因为我的表中不存在“activated”列。是的,我说我在最初的问题中已经更改了它。我要问的问题是如何删除激活码。一个简单的方法是将表放回原始状态,并使用正确的方法创建/注册帐户,而无需按照上述文档中所述激活。