I have a table named 'users' that is being used by Sentry however I removed the columns I didn't need such as activation codes and persist codes etc.
This is the structure of my table:
I am trying to log in using an account I created through 'Sentry::createUser()' however the 'UserNotActivatedException' keeps being thrown and prevents me from logging in.
This is my login code:
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!']);
}
}
This is the response that is being returned:
Is there any way to disable the activation check for Users in Sentry?
I have fixed the error by creating my own User class and setting the $activated variable to true. User Class:
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;
}
}
I also created two new migrations to add the 'persist_code' and 'last_login' columns to my table:
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');
});
}
}