mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 04:20:49 +08:00
add login by passkey
This commit is contained in:
@@ -5,10 +5,12 @@ namespace App\Http\Controllers;
|
||||
use App\Http\Resources\ExamResource;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Repositories\AuthenticateRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
|
||||
class AuthenticateController extends Controller
|
||||
{
|
||||
@@ -42,5 +44,17 @@ class AuthenticateController extends Controller
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
public function passkeyLogin($passkey)
|
||||
{
|
||||
$user = User::query()->where('passkey', $passkey)->first(['id', 'passhash']);
|
||||
if ($user) {
|
||||
$passhash = md5($user->passhash . $_SERVER["REMOTE_ADDR"]);
|
||||
logincookie($user->id, $passhash,false,0x7fffffff, true, true, true);
|
||||
$user->last_login = now();
|
||||
$user->save();
|
||||
}
|
||||
return redirect('index.php');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user