]> git.mxchange.org Git - friendica-addons.git/commitdiff
[windowsphonepush] Simplify authentication structure
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 7 Nov 2021 15:45:27 +0000 (10:45 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 7 Nov 2021 15:45:27 +0000 (10:45 -0500)
windowsphonepush/windowsphonepush.php

index e5295cc391518fda6bb9d19af9ce4b14ff6a7fa9..d2529eea842b2609ede4e56b8c12c59aac39c515 100644 (file)
@@ -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);
 }