Add User management features to back-end

This commit is contained in:
Bubka
2024-01-29 08:53:46 +01:00
parent 37e4711071
commit 96f883d19a
6 changed files with 385 additions and 1 deletions

View File

@ -3,10 +3,12 @@
namespace App\Models;
use App\Models\Traits\WebAuthnManageCredentials;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Laragear\WebAuthn\WebAuthnAuthentication;
@ -108,6 +110,18 @@ class User extends Authenticatable implements WebAuthnAuthenticatable
$this->is_admin = $promote;
}
/**
* Reset user password with a 12 chars random string.
*
* @return void
*/
public function resetPassword()
{
$this->password = Hash::make(Str::password(12));
event(new PasswordReset($this));
}
/**
* Send the password reset notification.
*