Skip to content

Commit 7fbc6fc

Browse files
committed
User token generator added
1 parent acd4e9a commit 7fbc6fc

3 files changed

Lines changed: 20 additions & 16 deletions

File tree

config/module.config.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@
5757
],
5858
],
5959
],
60+
'user-token' => [
61+
'type' => Literal::class,
62+
'options' => [
63+
'route' => '/user-token',
64+
'defaults' => [
65+
'controller' => Controller\UserController::class,
66+
'action' => 'user-token',
67+
],
68+
],
69+
]
6070
],
6171
],
6272
'controllers' => [

src/Controller/UserController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Zend\Hydrator\ClassMethods;
88
use Zend\Mvc\Controller\AbstractActionController;
99
use Zend\ServiceManager\ServiceLocatorInterface;
10+
use Zend\View\Model\JsonModel;
1011
use Zend\View\Model\ViewModel;
1112
use ProspectOne\UserModule\Entity\User;
1213
use ProspectOne\UserModule\Form\UserForm;
@@ -394,6 +395,15 @@ public function getUserRole($user)
394395

395396
return $rolecurrent['role_id'];
396397
}
398+
399+
/**
400+
* @return JsonModel
401+
*/
402+
public function userTokenAction()
403+
{
404+
$result = $this->userManager->generateToken();
405+
return new JsonModel($result);
406+
}
397407
}
398408

399409

src/Form/Factory/UserFormFactory.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,6 @@
1717
*/
1818
class UserFormFactory implements FactoryInterface
1919
{
20-
/**
21-
* @var ContainerInterface
22-
*/
23-
private $container;
24-
25-
/**
26-
* UserFormFactory constructor.
27-
* @param ContainerInterface|null $container
28-
*/
29-
public function __construct(?ContainerInterface $container = null)
30-
{
31-
if (!empty($container)) {
32-
$this->container = $container;
33-
}
34-
}
35-
3620
/**
3721
* Create an object
3822
*

0 commit comments

Comments
 (0)