当前位置: 首页>>代码示例>>PHP>>正文


PHP Authentication::generateToken方法代码示例

本文整理汇总了PHP中Pimcore\Tool\Authentication::generateToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Authentication::generateToken方法的具体用法?PHP Authentication::generateToken怎么用?PHP Authentication::generateToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pimcore\Tool\Authentication的用法示例。


在下文中一共展示了Authentication::generateToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: lostpasswordAction

 public function lostpasswordAction()
 {
     $username = $this->getParam("username");
     if ($username) {
         $user = User::getByName($username);
         if (!$user instanceof User) {
             $this->view->error = "user unknown";
         } else {
             if ($user->isActive()) {
                 if ($user->getEmail()) {
                     $token = Tool\Authentication::generateToken($username, $user->getPassword());
                     $uri = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost();
                     $loginUrl = $uri . "/admin/login/login/?username=" . $username . "&token=" . $token . "&reset=true";
                     try {
                         $mail = Tool::getMail(array($user->getEmail()), "Pimcore lost password service");
                         $mail->setIgnoreDebugMode(true);
                         $mail->setBodyText("Login to pimcore and change your password using the following link. This temporary login link will expire in 30 minutes: \r\n\r\n" . $loginUrl);
                         $mail->send();
                         $this->view->success = true;
                     } catch (\Exception $e) {
                         $this->view->error = "could not send email";
                     }
                 } else {
                     $this->view->error = "user has no email address";
                 }
             } else {
                 $this->view->error = "user inactive";
             }
         }
     }
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:31,代码来源:LoginController.php

示例2: getTokenLoginLinkAction

 public function getTokenLoginLinkAction()
 {
     $user = User::getById($this->getParam("id"));
     if ($user->isAdmin() && !$this->getUser()->isAdmin()) {
         throw new \Exception("Only admin users are allowed to login as an admin user");
     }
     if ($user) {
         $token = Tool\Authentication::generateToken($user->getName(), $user->getPassword());
         $r = $this->getRequest();
         $link = $r->getScheme() . "://" . $r->getHttpHost() . "/admin/login/login/?username=" . $user->getName() . "&token=" . $token;
         $this->_helper->json(["link" => $link]);
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:13,代码来源:UserController.php


注:本文中的Pimcore\Tool\Authentication::generateToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。