From 6129eb1623f28e1afc585d2756f6ff4f5315e754 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Thu, 17 May 2018 00:21:06 +0200
Subject: [PATCH] OpenId possibly fixed: - The LightOpenId class' constructor
 now requires the hostname from where the   requested started, added it now -
 sometimes need to invoke get_app() as $a was not around
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Roland Häder <roland@mxchange.org>
---
 mod/openid.php       | 2 +-
 mod/settings.php     | 2 +-
 src/Model/User.php   | 2 +-
 src/Module/Login.php | 3 ++-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/mod/openid.php b/mod/openid.php
index af7016c32..2c284f76d 100644
--- a/mod/openid.php
+++ b/mod/openid.php
@@ -19,7 +19,7 @@ function openid_content(App $a) {
 
 	if((x($_GET,'openid_mode')) && (x($_SESSION,'openid'))) {
 
-		$openid = new LightOpenID;
+		$openid = new LightOpenID($a->get_hostname());
 
 		if($openid->validate()) {
 
diff --git a/mod/settings.php b/mod/settings.php
index c7e61cbe3..23869913a 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -543,7 +543,7 @@ function settings_post(App $a)
 	if ($openid != $a->user['openid'] || (strlen($openid) && (!strlen($openidserver)))) {
 		if (Network::isUrlValid($openid)) {
 			logger('updating openidserver');
-			$open_id_obj = new LightOpenID;
+			$open_id_obj = new LightOpenID($a->get_hostname());
 			$open_id_obj->identity = $openid;
 			$openidserver = $open_id_obj->discover($open_id_obj->identity);
 		} else {
diff --git a/src/Model/User.php b/src/Model/User.php
index 41d26ee19..9b0f409e1 100644
--- a/src/Model/User.php
+++ b/src/Model/User.php
@@ -359,7 +359,7 @@ class User
 				$_SESSION['register'] = 1;
 				$_SESSION['openid'] = $openid_url;
 
-				$openid = new LightOpenID;
+				$openid = new LightOpenID($a->get_hostname());
 				$openid->identity = $openid_url;
 				$openid->returnUrl = System::baseUrl() . '/openid';
 				$openid->required = ['namePerson/friendly', 'contact/email', 'namePerson'];
diff --git a/src/Module/Login.php b/src/Module/Login.php
index fe3305a91..7d6470620 100644
--- a/src/Module/Login.php
+++ b/src/Module/Login.php
@@ -90,7 +90,8 @@ class Login extends BaseModule
 
 		// Otherwise it's probably an openid.
 		try {
-			$openid = new LightOpenID;
+			$a = get_app();
+			$openid = new LightOpenID($a->get_hostname());
 			$openid->identity = $openid_url;
 			$_SESSION['openid'] = $openid_url;
 			$_SESSION['remember'] = $remember;