mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-15 05:00:49 +08:00
fix installation for beta5
This commit is contained in:
@@ -29,7 +29,9 @@ class UserResource extends JsonResource
|
||||
'downloaded_text' => mksize($this->downloaded),
|
||||
'bonus' => $this->seedbonus,
|
||||
'seedtime' => $this->seedtime,
|
||||
'seedtime_text' => mkprettytime($this->seedtime),
|
||||
'leechtime' => $this->leechtime,
|
||||
'leechtime_text' => mkprettytime($this->leechtime),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@@ -10,16 +11,17 @@ class AuthenticateRepository extends BaseRepository
|
||||
{
|
||||
$user = User::query()
|
||||
->where('username', $username)
|
||||
->firstOrFail(['id', 'secret', 'passhash']);
|
||||
if (md5($user->secret . $password . $user->secret) != $user->passhash) {
|
||||
throw new \InvalidArgumentException('username or password invalid');
|
||||
->first(array_merge(User::$commonFields, ['secret', 'passhash']));
|
||||
if (!$user || md5($user->secret . $password . $user->secret) != $user->passhash) {
|
||||
throw new \InvalidArgumentException('Username or password invalid.');
|
||||
}
|
||||
$token = DB::transaction(function () use ($user) {
|
||||
$tokenName = __METHOD__ . __LINE__;
|
||||
$token = DB::transaction(function () use ($user, $tokenName) {
|
||||
$user->tokens()->delete();
|
||||
$tokenResult = $user->createToken(__CLASS__ . __FUNCTION__ . __LINE__);
|
||||
$tokenResult = $user->createToken($tokenName);
|
||||
return $tokenResult->plainTextToken;
|
||||
});
|
||||
$result = $user->toArray();
|
||||
$result = (new UserResource($user))->response()->getData(true)['data'];
|
||||
$result['token'] = $token;
|
||||
return $result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user