Skip to content

Commit

Permalink
EZP-28917: As a Developer I want API to manipulate User Tokens (#2270)
Browse files Browse the repository at this point in the history
* EZP-28917: As a Developer I want API to manipulate User Tokens

* EZP-28917: Implemented integration tests for User Token APIs

* EZP-28917: Implemented checking for user / password policy

It allows Users w/o content / edit policy to update their password

BC: If User has content / edit policy, but no user / password policy, updating password works as well
  • Loading branch information
mikadamczyk authored and alongosz committed Mar 12, 2018
1 parent 47419b8 commit 43d8cd2
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Persistence/User/Handler.php
Expand Up @@ -65,13 +65,38 @@ public function loadByLogin($login);
*/
public function loadByEmail($email);

/**
* Loads user with user hash.
*
* @param string $hash
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If user is not found
*
* @return \eZ\Publish\SPI\Persistence\User
*/
public function loadUserByToken($hash);

/**
* Update the user information specified by the user struct.
*
* @param \eZ\Publish\SPI\Persistence\User $user
*/
public function update(User $user);

/**
* Update the user information specified by the user token struct.
*
* @param \eZ\Publish\SPI\Persistence\User\UserTokenUpdateStruct $userTokenUpdateStruct
*/
public function updateUserToken(UserTokenUpdateStruct $userTokenUpdateStruct);

/**
* Expires user token with user hash.
*
* @param string $hash
*/
public function expireUserToken($hash);

/**
* Delete user with the given ID.
*
Expand Down
39 changes: 39 additions & 0 deletions Persistence/User/UserTokenUpdateStruct.php
@@ -0,0 +1,39 @@
<?php

/**
* File containing the UserTokenUpdateStruct class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Publish\SPI\Persistence\User;

use eZ\Publish\SPI\Persistence\ValueObject;

/**
* This update struct is used to update User Tokens (formerly known as User account keys).
*/
class UserTokenUpdateStruct extends ValueObject
{
/**
* Hash key date for user account.
*
* @var string
*/
public $hashKey;

/**
* Time to which the token is valid
* Unix timestamp.
*
* @var int
*/
public $time;

/**
* The user to whom the token belongs.
*
* @var int
*/
public $userId;
}

0 comments on commit 43d8cd2

Please sign in to comment.