From 2bae6a41c39e0431f6dd65365918c8661fd32c6c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 7 Nov 2021 10:45:27 -0500 Subject: [PATCH] [windowsphonepush] Simplify authentication structure --- windowsphonepush/windowsphonepush.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index e5295cc3..d2529eea 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -442,20 +442,13 @@ function windowsphonepush_login(App $a) try { $user_id = User::getIdFromPasswordAuthentication($_SERVER['PHP_AUTH_USER'], trim($_SERVER['PHP_AUTH_PW'])); - if ($user_id) { - $record = DBA::selectFirst('user', [], ['uid' => $user_id]); - } + $record = DBA::selectFirst('user', [], ['uid' => $user_id]); + DI::auth()->setForUser($a, $record); + DI::session()->set('allow_api', true); + Hook::callAll('logged_in', $record); } catch (Exception $ex) { - $record = []; - } - - if (empty($record)) { Logger::info('API_login failure: ' . print_r($_SERVER, true)); header('WWW-Authenticate: Basic realm="Friendica"'); throw new UnauthorizedException('This api requires login'); } - - DI::auth()->setForUser($a, $record); - DI::session()->set('allow_api', true); - Hook::callAll('logged_in', $record); } -- 2.39.5