Skip to content

Commit

Permalink
Merge branch '2.2' into 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed May 25, 2021
2 parents a7570ed + 3f8dcdb commit bd127ca
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 11 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Automatic Changelog Generator for tag

on:
push:
tags:
- 'v*'
- '!v*-alpha*'

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Set Environment
run: |
echo "BUILD_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Get previous release tag based on type
id: prevrelease
uses: ibexa/version-logic-action@master
with:
currentTag: ${{ env.BUILD_TAG }}

- name: Generate changelog
id: changelog
uses: ibexa/changelog-generator-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
jira_token: ${{ secrets.JIRA_TOKEN }}
currentTag: ${{ env.BUILD_TAG }}
previousTag: ${{ steps.prevrelease.outputs.previousTag }}

- name: Print the changelog
run: echo "${{ steps.changelog.outputs.changelog }}"

- name: Create Release
id: create_release
uses: zendesk/action-create-release@v1
with:
tag_name: ${{ env.BUILD_TAG }}
body: |
${{ steps.changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 17 additions & 11 deletions src/lib/EventListener/UserMenuListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,29 @@

namespace EzSystems\EzPlatformUser\EventListener;

use eZ\Publish\API\Repository\PermissionResolver;
use eZ\Publish\API\Repository\UserService;
use EzSystems\EzPlatformAdminUi\Menu\Event\ConfigureMenuEvent;
use JMS\TranslationBundle\Translation\TranslationContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use JMS\TranslationBundle\Model\Message;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;

class UserMenuListener implements EventSubscriberInterface, TranslationContainerInterface
{
public const ITEM_CHANGE_PASSWORD = 'user__change_password';

/** @var \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface */
private $tokenStorage;
/** @var \eZ\Publish\API\Repository\PermissionResolver */
private $permissionResolver;

/**
* @param \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokenStorage
*/
public function __construct(TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
/** @var \eZ\Publish\API\Repository\UserService */
private $userService;

public function __construct(
PermissionResolver $permissionResolver,
UserService $userService
) {
$this->permissionResolver = $permissionResolver;
$this->userService = $userService;
}

/**
Expand All @@ -43,9 +47,11 @@ public static function getSubscribedEvents(): array
public function onUserMenuConfigure(ConfigureMenuEvent $event): void
{
$menu = $event->getMenu();
$token = $this->tokenStorage->getToken();

if (null !== $token && \is_object($token->getUser())) {
$currentUserId = $this->permissionResolver->getCurrentUserReference()->getUserId();
$currentUser = $this->userService->loadUser($currentUserId);

if ($this->permissionResolver->canUser('user', 'password', $currentUser, [$currentUser])) {
$menu->addChild(
self::ITEM_CHANGE_PASSWORD,
[
Expand Down

0 comments on commit bd127ca

Please sign in to comment.