浏览代码

Fix OC.getCurrentUser() on guest pages

Signed-off-by: Joas Schilling <coding@schilljs.com>
Joas Schilling 5 年之前
父节点
当前提交
08688af275
共有 2 个文件被更改,包括 9 次插入1 次删除
  1. 5 1
      core/templates/layout.guest.php
  2. 4 0
      lib/private/TemplateLayout.php

+ 5 - 1
core/templates/layout.guest.php

@@ -1,6 +1,10 @@
 <!DOCTYPE html>
 <html class="ng-csp" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" data-locale="<?php p($_['locale']); ?>" >
-	<head data-requesttoken="<?php p($_['requesttoken']); ?>">
+	<head
+<?php if ($_['user_uid']) { ?>
+	data-user="<?php p($_['user_uid']); ?>" data-user-displayname="<?php p($_['user_displayname']); ?>"
+<?php } ?>
+ data-requesttoken="<?php p($_['requesttoken']); ?>">
 		<meta charset="utf-8">
 		<title>
 		<?php p($theme->getTitle()); ?>

+ 4 - 0
lib/private/TemplateLayout.php

@@ -122,6 +122,10 @@ class TemplateLayout extends \OC_Template {
 			parent::__construct('core', 'layout.guest');
 			\OC_Util::addStyle('guest');
 			$this->assign('bodyid', 'body-login');
+
+			$userDisplayName = \OC_User::getDisplayName();
+			$this->assign('user_displayname', $userDisplayName);
+			$this->assign('user_uid', \OC_User::getUser());
 		} else if ($renderAs == 'public') {
 			parent::__construct('core', 'layout.public');
 			$this->assign( 'appid', $appId );