model = new User(); } #[NoReturn] public function actionAuth(): void { $request = new Request(); $data = $request->post(); $model = $this->model->where('username', $data['username'])->first(); $res = []; if ($model) { if (password_verify($data["password"], $model->password_hash)) { $model->access_token_expires_at = date("Y-m-d H:i:s", strtotime(App::$secure['token_expired_time'])); switch (App::$secure['token_type']){ case "JWT": $model->access_token = TokenService::JWT($_ENV['SECRET_KEY'], 'HS256'); default: $model->access_token = TokenService::random_bytes(20); } $res = [ "access_token" => $model->access_token, "access_token_expires_at" => $model->access_token_expires_at, ]; } $model->save(); } $this->renderApi($res); } }