Skip to content

Commit

Permalink
Add email to OC.getCurrentUser()
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Petry committed Jan 16, 2018
1 parent c14a18f commit c4815b1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion core/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,13 @@ var OC = {
if (_.isUndefined(this._currentUserDisplayName)) {
this._currentUserDisplayName = document.getElementsByTagName('head')[0].getAttribute('data-user-displayname');
}
if (_.isUndefined(this._currentUserEmail)) {
this._currentUserEmail = document.getElementsByTagName('head')[0].getAttribute('data-user-email') || null;
}
return {
uid: this.currentUser,
displayName: this._currentUserDisplayName
displayName: this._currentUserDisplayName,
email: this._currentUserEmail
};
},

Expand Down
2 changes: 1 addition & 1 deletion core/templates/layout.user.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html class="ng-csp" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" >
<head data-user="<?php p($_['user_uid']); ?>" data-user-displayname="<?php p($_['user_displayname']); ?>" data-requesttoken="<?php p($_['requesttoken']); ?>">
<head data-user="<?php p($_['user_uid']); ?>" data-user-displayname="<?php p($_['user_displayname']); ?>" data-user-email="<?php p($_['user_email']) ?>" data-requesttoken="<?php p($_['requesttoken']); ?>">
<meta charset="utf-8">
<title>
<?php
Expand Down
8 changes: 5 additions & 3 deletions lib/private/TemplateLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ public function __construct( $renderAs, $appId = '' ) {
break;
}
}
$userDisplayName = \OC_User::getDisplayName();
$this->assign('user_displayname', $userDisplayName);
$this->assign('user_uid', \OC_User::getUser());

$user = \OC::$server->getUserSession()->getUser();
$this->assign('user_displayname', $user->getDisplayName());
$this->assign('user_email', $user->getEMailAddress());
$this->assign('user_uid', $user->getUID());
$this->assign('enableAvatars', $this->config->getSystemValue('enable_avatars', true) === true);

if (\OC_User::getUser() === false) {
Expand Down

0 comments on commit c4815b1

Please sign in to comment.