Skip to content

Commit b9bfdcd

Browse files
committed
Update User model
1 parent 5f08788 commit b9bfdcd

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

app/Models/User.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Illuminate\Database\Eloquent\Relations\HasOne;
1111
use Illuminate\Foundation\Auth\User as Authenticatable;
1212
use Illuminate\Notifications\Notifiable;
13+
use Illuminate\Support\Facades\Hash;
14+
use Laravel\Passport\Bridge\Client;
1315
use Laravel\Passport\Contracts\OAuthenticatable;
1416
use Laravel\Passport\HasApiTokens;
1517

@@ -284,6 +286,18 @@ public function getOrCreateDataSettings(): UserDataSettings
284286
]);
285287
}
286288

289+
public function findForPassport(string $username, Client $client): User
290+
{
291+
return $this->where('email', $username)
292+
->where('status', '=', 1)
293+
->first();
294+
}
295+
296+
public function validateForPassportPasswordGrant(string $password): bool
297+
{
298+
return $this->status == 1 && Hash::check($password, $this->password);
299+
}
300+
287301
public function getTotalWatchTimeInHours(): int
288302
{
289303
return (int) ($this->videoViews()->sum('watch_time_seconds') / 3600);

0 commit comments

Comments
 (0)