Skip to content

Commit

Permalink
updating user model
Browse files Browse the repository at this point in the history
  • Loading branch information
tnylea committed Jun 15, 2024
1 parent 58c884c commit da1fba2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 6 additions & 4 deletions resources/views/pages/auth/login.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
use App\Models\User;
use Illuminate\Auth\Events\Login;
use function Laravel\Folio\{middleware, name};
use Livewire\Attributes\Validate;
Expand Down Expand Up @@ -34,9 +33,12 @@
public $userSocialProviders = [];
public $userModel = null;
public function mount(){
$this->loadConfigs();
$this->twoFactorEnabled = $this->settings->enable_2fa;
$this->userModel = app(config('auth.providers.users.model'));
}
public function editIdentity(){
Expand All @@ -54,7 +56,7 @@ public function authenticate()
if(!$this->showPasswordField){
$this->validateOnly('email');
$userTryingToValidate = \Devdojo\Auth\Models\User::where('email', $this->email)->first();
$userTryingToValidate = $this->userModel->where('email', $this->email)->first();
if(!is_null($userTryingToValidate)){
if(is_null($userTryingToValidate->password)){
$this->userSocialProviders = [];
Expand Down Expand Up @@ -82,7 +84,7 @@ public function authenticate()
return;
}
$userAttemptingLogin = User::where('email', $this->email)->first();
$userAttemptingLogin = $this->userModel->where('email', $this->email)->first();
if(!isset($userAttemptingLogin->id)){
$this->addError('password', trans('auth.failed'));
Expand All @@ -102,7 +104,7 @@ public function authenticate()
$this->addError('password', trans('auth.failed'));
return;
}
event(new Login(auth()->guard('web'), User::where('email', $this->email)->first(), true));
event(new Login(auth()->guard('web'), $this->userModel->where('email', $this->email)->first(), true));
if(session()->get('url.intended') != route('logout.get')){
redirect()->intended(config('devdojo.auth.settings.redirect_after_auth'));
Expand Down
6 changes: 1 addition & 5 deletions resources/views/pages/auth/register.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
use Devdojo\Auth\Models\User;
use Devdojo\Auth\Models\SocialProvider;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
Expand Down Expand Up @@ -29,9 +28,6 @@
public $showEmailField = true;
public $showPasswordField = false;
public function rules()
{
$nameValidationRules = [];
Expand Down Expand Up @@ -84,7 +80,7 @@ public function register()
$userData['name'] = $this->name;
}
$user = User::create($userData);
$user = app(config('auth.providers.users.model'))->create($userData);
event(new Registered($user));
Expand Down

0 comments on commit da1fba2

Please sign in to comment.