From 3079771f297009dc757d48ae4771b4fa9981d827 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Fri, 11 Nov 2022 16:39:52 +0100 Subject: [PATCH] Move ServiceRemoteAutoLogin to plugin/extension --- plugins/login-remote/LICENSE | 20 ++++++++ plugins/login-remote/index.php | 51 +++++++++++++++++++ .../app/libraries/RainLoop/ServiceActions.php | 27 ---------- 3 files changed, 71 insertions(+), 27 deletions(-) create mode 100644 plugins/login-remote/LICENSE create mode 100644 plugins/login-remote/index.php diff --git a/plugins/login-remote/LICENSE b/plugins/login-remote/LICENSE new file mode 100644 index 000000000..f709b02e2 --- /dev/null +++ b/plugins/login-remote/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2016 RainLoop Team + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/plugins/login-remote/index.php b/plugins/login-remote/index.php new file mode 100644 index 000000000..9efba76b9 --- /dev/null +++ b/plugins/login-remote/index.php @@ -0,0 +1,51 @@ +addPartHook('RemoteAutoLogin', 'ServiceRemoteAutoLogin'); + } + + public function ServiceRemoteAutoLogin() : bool + { + $oActions = \RainLoop\Api::Actions(); + + $oException = null; + $oAccount = null; + + $sEmail = $_ENV['REMOTE_USER'] ?? ''; + $sPassword = $_ENV['REMOTE_PASSWORD'] ?? ''; + + if (\strlen($sEmail) && \strlen($sPassword)) + { + try + { + $oAccount = $oActions->LoginProcess($sEmail, $sPassword); + if ($oAccount instanceof \RainLoop\Model\MainAccount) { + $oActions->SetAuthToken($oAccount); + } + } + catch (\Throwable $oException) + { + $oLogger = $oActions->Logger(); + $oLogger && $oLogger->WriteException($oException); + } + } + + $oActions->Location('./'); + return true; + } + +} diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php index 8ed22f7da..d2c6da422 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php @@ -734,33 +734,6 @@ class ServiceActions return ''; } - public function ServiceRemoteAutoLogin() : string - { - $oException = null; - $oAccount = null; - - $sEmail = $_ENV['REMOTE_USER'] ?? ''; - $sPassword = $_ENV['REMOTE_PASSWORD'] ?? ''; - - if (\strlen($sEmail) && \strlen(\trim($sPassword))) - { - try - { - $oAccount = $this->oActions->LoginProcess($sEmail, $sPassword); - if ($oAccount instanceof Model\MainAccount) { - $this->oActions->SetAuthToken($oAccount); - } - } - catch (\Throwable $oException) - { - $this->Logger()->WriteException($oException); - } - } - - $this->oActions->Location('./'); - return ''; - } - public function ServiceExternalSso() : string { $this->oHttp->ServerNoCache();