mirror of https://github.com/flarum/flarum
SSO targetUrl setup
parent
1e61382ca3
commit
24a213ebd7
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue