channel delegation: push current identity and pop it on logout from the delegated channel. This fixes the known issue of being forced to log back in after leaving the delegated channel.

This commit is contained in:
zotlabs 2018-04-11 17:40:04 -07:00
parent 90580a860b
commit 2fa9645dfc
6 changed files with 22 additions and 6 deletions

View File

@ -5,7 +5,12 @@ namespace Zotlabs\Module;
class Logout extends \Zotlabs\Web\Controller { class Logout extends \Zotlabs\Web\Controller {
function init() { function init() {
if($_SESSION['delegate'] && $_SESSION['delegate_push']) {
$_SESSION = $_SESSION['delegate_push'];
}
else {
\App::$session->nuke(); \App::$session->nuke();
}
goaway(z_root()); goaway(z_root());
} }

View File

@ -112,6 +112,8 @@ class Magic extends \Zotlabs\Web\Controller {
if($r && intval($r[0]['channel_id'])) { if($r && intval($r[0]['channel_id'])) {
$allowed = perm_is_allowed($r[0]['channel_id'],get_observer_hash(),'delegate'); $allowed = perm_is_allowed($r[0]['channel_id'],get_observer_hash(),'delegate');
if($allowed) { if($allowed) {
$tmp = $_SESSION;
$_SESSION['delegate_push'] = $tmp;
$_SESSION['delegate_channel'] = $r[0]['channel_id']; $_SESSION['delegate_channel'] = $r[0]['channel_id'];
$_SESSION['delegate'] = get_observer_hash(); $_SESSION['delegate'] = get_observer_hash();
$_SESSION['account_id'] = intval($r[0]['channel_account_id']); $_SESSION['account_id'] = intval($r[0]['channel_account_id']);

View File

@ -145,8 +145,17 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) &&
// process logout request // process logout request
$args = array('channel_id' => local_channel()); $args = array('channel_id' => local_channel());
call_hooks('logging_out', $args); call_hooks('logging_out', $args);
if($_SESSION['delegate'] && $_SESSION['delegate_push']) {
$_SESSION = $_SESSION['delegate_push'];
info( t('Delegation session ended.') . EOL);
}
else {
App::$session->nuke(); App::$session->nuke();
info( t('Logged out.') . EOL); info( t('Logged out.') . EOL);
}
goaway(z_root()); goaway(z_root());
} }

View File

@ -1001,11 +1001,11 @@ function bbcode($Text, $options = []) {
} }
// Check for strike-through text // Check for strike-through text
if (strpos($Text,'[s]') !== false) { if (strpos($Text,'[s]') !== false) {
$Text = preg_replace("(\[s\](.*?)\[\/s\])ism", '<strike>$1</strike>', $Text); $Text = preg_replace("(\[s\](.*?)\[\/s\])ism", '<span style="text-decoration: line-through;">$1</span>', $Text);
} }
// Check for over-line text // Check for over-line text
if (strpos($Text,'[o]') !== false) { if (strpos($Text,'[o]') !== false) {
$Text = preg_replace("(\[o\](.*?)\[\/o\])ism", '<span class="overline">$1</span>', $Text); $Text = preg_replace("(\[o\](.*?)\[\/o\])ism", '<span style="text-decoration: overline;">$1</span>', $Text);
} }
if (strpos($Text,'[sup]') !== false) { if (strpos($Text,'[sup]') !== false) {
$Text = preg_replace("(\[sup\](.*?)\[\/sup\])ism", '<sup>$1</sup>', $Text); $Text = preg_replace("(\[sup\](.*?)\[\/sup\])ism", '<sup>$1</sup>', $Text);

View File

@ -164,6 +164,7 @@ function html2bbcode($message)
node2bbcode($doc, 'b', array(), '[b]', '[/b]'); node2bbcode($doc, 'b', array(), '[b]', '[/b]');
node2bbcode($doc, 'i', array(), '[i]', '[/i]'); node2bbcode($doc, 'i', array(), '[i]', '[/i]');
node2bbcode($doc, 'u', array(), '[u]', '[/u]'); node2bbcode($doc, 'u', array(), '[u]', '[/u]');
node2bbcode($doc, 's', array(), '[s]', '[/s]');
node2bbcode($doc, 'big', array(), "[size=large]", "[/size]"); node2bbcode($doc, 'big', array(), "[size=large]", "[/size]");
node2bbcode($doc, 'small', array(), "[size=small]", "[/size]"); node2bbcode($doc, 'small', array(), "[size=small]", "[/size]");

View File

@ -1465,7 +1465,6 @@ function b2h(s) {
rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />"); rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />"); rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
// FIXME - add zid()
rep(/\[zrl=([^\]]+)\](.*?)\[\/zrl\]/gi,"<a href=\"$1" + '?f=&zid=' + zid + "\">$2</a>"); rep(/\[zrl=([^\]]+)\](.*?)\[\/zrl\]/gi,"<a href=\"$1" + '?f=&zid=' + zid + "\">$2</a>");
rep(/\[zrl\](.*?)\[\/zrl\]/gi,"<a href=\"$1" + '?f=&zid=' + zid + "\">$1</a>"); rep(/\[zrl\](.*?)\[\/zrl\]/gi,"<a href=\"$1" + '?f=&zid=' + zid + "\">$1</a>");
rep(/\[zmg=(.*?)x(.*?)\](.*?)\[\/zmg\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3" + '?f=&zid=' + zid + "\" />"); rep(/\[zmg=(.*?)x(.*?)\](.*?)\[\/zmg\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3" + '?f=&zid=' + zid + "\" />");