Search code examples
phplaravellaravel-5.3cartalyst-sentinel

Laravel cartalyst sentinel - Softdelete and restore a user


How do I soft delete and restore user using cartalyst sentinel package. I am using it for authentication. My main problem is I cannot find a function which retrieves a soft deleted user in sentinel. if I fetch a user using User::withTrashed()-> then I cannot match a password in the request with the hashed password in the DB to manually verify identity without using sentinel.

I have tried using $hasher = Sentinel::getHasher(); to get the hash of the password and match it with the password in the DB. but it is not matching. Maybe I am missing something.

This is not working because the findUserById is not returning the user

$userCheck = User::withTrashed()->where('email', $request->get('email'))->first();
$user = Sentinel::findUserById($userCheck->id);
$user = Sentinel::validateCredentials($user, $credentials);

Solution

  • I have found the answer. We should use the following code to get the soft deleted user with Sentinel

    $user = Sentinel::createModel()->withTrashed()->find(34);