SSO targetUrl setup

pull/42/head
Ali Gajani 2017-09-18 18:49:52 +01:00
parent 1e61382ca3
commit 24a213ebd7
3 changed files with 8 additions and 4 deletions

View File

@ -41,10 +41,12 @@ class SSOController
/**
* Redirects a user back to the forum.
* @param $targetUrl
*/
public function redirectToForum()
public function redirectToForum($targetUrl)
{
header('Location: ' . $this->config['flarum_url']);
$targetUrl = (!is_null($targetUrl)) ? $targetUrl : '';
header('Location: ' . $this->config['flarum_url'] . $targetUrl);
die();
}

View File

@ -3,6 +3,7 @@
require_once('SSOController.php');
$authToken = $_GET['auth_token'];
$targetUrl = (isset($_GET['target_url'])) ? $_GET['target_url'] : null;
if (!isset($authToken) || empty($authToken) || $authToken == "") echo 'Login failed';
$decodedTestData = json_decode(base64_decode($authToken));
@ -12,4 +13,4 @@ $avatarUrl = $decodedTestData->avatarUrl;
$forum = new SSOController();
$forum->login($username, $email, $avatarUrl);
$forum->redirectToForum();
$forum->redirectToForum($targetUrl);

View File

@ -200,7 +200,8 @@
console.log(fake);
console.log(encoded);
var authRedirect = "/auth.php?auth_token=" + encoded;
var targetUrl = "&target_url=/t/parent-tag";
var authRedirect = "/auth.php?auth_token=" + encoded + targetUrl;
$('.visit-link').attr("href", authRedirect);
$('.profile-userpic .img-responsive').attr("src", randomAvatar);