• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Security\User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Nette\Security\User的典型用法代码示例。如果您正苦于以下问题:PHP User类的具体用法?PHP User怎么用?PHP User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: login

 public function login($roleName)
 {
     $identity = new User();
     $identity->id = 0;
     $identity->email = '[email protected]';
     $identity->name = 'Name';
     $identity->surname = 'Surname';
     $identity->active = TRUE;
     $identity->registered = new DateTime();
     $identity->lastLogin = new DateTime();
     $identity->lang = 'cs';
     switch ($roleName) {
         case 'admin':
             $identity->id = 1;
             $role = new Role();
             $role->id = 1;
             $role->name = 'administrator';
             $identity->addRole($role);
             break;
         default:
             $role = new Role();
             $role->id = 1;
             $role->name = $roleName;
             $identity->addRole($role);
     }
     $this->user->login($identity);
 }
开发者ID:b4nan,项目名称:utils,代码行数:27,代码来源:PresenterTestCase.php


示例2: __construct

 public function __construct(DbTable\Oznam_ucast $oznam_ucast, DbTable\Oznam_volba $oznam_volba, Nette\Security\User $user)
 {
     parent::__construct();
     $this->oznam_ucast = $oznam_ucast;
     $this->oznam_volba = $oznam_volba;
     $this->id_user_profiles = $user->getId();
 }
开发者ID:petak23,项目名称:echo-msz,代码行数:7,代码来源:Potvrd_ucast.php


示例3: onSuccessCommentRemoval

 public function onSuccessCommentRemoval(Comment $comment, $id)
 {
     /** @var \Users\User $user */
     $user = $this->user->getIdentity();
     $pageLink = $this->linkGenerator->link('Pages:Front:Page:show', ['internal_id' => $comment->getPageId()]);
     $this->appEventLogger->saveLog(sprintf('User [%s#%s] <b>has REMOVED</b> the Comment [%s#] of Author [%s] on the <a href="%s">Page [%s#%s]</a>', $user->getId(), $user->getUsername(), $id, $comment->getAuthor(), $pageLink, $comment->getPageId(), $comment->getPageTitle()), 'page_comment_release', $user->getId());
 }
开发者ID:blitzik,项目名称:CMS,代码行数:7,代码来源:PageCommentSubscriber.php


示例4: processCreateInvitation

 public function processCreateInvitation(Form $form)
 {
     $value = $form->getValues();
     $invitation = new Invitation($value['email'], $this->user->getIdentity());
     try {
         /** @var EntityResultObject $resultObject */
         $resultObject = $this->invitationsFacade->createInvitation($invitation);
         $this->flashMessage('Registrační pozvánka byla vytvořena.', 'success');
         if (!$resultObject->hasNoErrors()) {
             $error = $resultObject->getFirstError();
             $this->flashMessage($error['message'], $error['type']);
         }
     } catch (InvitationCreationAttemptException $ca) {
         $this->flashMessage('Pozvánku nebyla vytvořena. Zkuste akci opakovat později.', 'error');
     } catch (UserAlreadyExistsException $uae) {
         $form->addError('Pozvánku nelze odeslat. Uživatel s E-Mailem ' . $value['email'] . ' je již zaregistrován.');
         return;
     } catch (InvitationAlreadyExistsException $iae) {
         $form->addError('Někdo jiný již odeslal pozvánku uživateli s E-mailem ' . $value['email']);
         return;
     } catch (DBALException $e) {
         $this->flashMessage('Při vytváření pozvánky došlo k chybě. Zkuste akci opakovat později.', 'error');
     }
     $this->redirect('this');
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:25,代码来源:InvitationGenerationControl.php


示例5: authorize

 /**
  * @inheritdoc
  */
 public function authorize($resource, $action, $parameters = NULL)
 {
     if (!$this->user->isLoggedIn()) {
         throw new AuthorizationException('User is not logged in.');
     }
     return TRUE;
 }
开发者ID:inteve,项目名称:authorizator,代码行数:10,代码来源:UserLoggedAuthorizator.php


示例6:

 */
class EditCategoriFormFactory
{
    /** @var DbTable\User_categories */
    private $user_categories;
    /** @var array */
    private $urovneReg;
    /** @var int */
开发者ID:petak23,项目名称:echo-msz,代码行数:8,代码来源:EditCategoriFormFactory.php


示例7: getUserSection

 /**
  * @return \Nette\Database\Table\Selection
  */
 public function getUserSection()
 {
     $selection = $this->sectionFacade->all();
     if (!$this->user->getIdentity()->super) {
         $this->sectionFilter->filterId($selection, $this->user->getIdentity()->sections);
     }
     return $selection;
 }
开发者ID:kysela-petr,项目名称:generator-kysela,代码行数:11,代码来源:UserSection.php


示例8: onLoggedOut

 public function onLoggedOut(Security $security)
 {
     // BUG: Nette\Security\User 2.1 fires onLoggedOut before clearing storage
     if ($user = $this->repository->find($security->getIdentity()->getId())) {
         $security->getStorage()->setAuthenticated(FALSE);
         $this->user->signOut($user);
     }
 }
开发者ID:rixxi,项目名称:user,代码行数:8,代码来源:Listener.php


示例9: authenticate

 /**
  * @param Method $element
  * @throws \Flame\Rest\Security\ForbiddenRequestException
  */
 public function authenticate(Method $element)
 {
     $user = (array) $element->getAnnotation('User');
     if (in_array('loggedIn', $user)) {
         if (!$this->user->isLoggedIn()) {
             throw new ForbiddenRequestException('Please sign in.');
         }
     }
 }
开发者ID:Budry,项目名称:TinyREST,代码行数:13,代码来源:SessionAuthenticator.php


示例10: __construct

 public function __construct(array $config, Nette\Security\User $user)
 {
     parent::__construct($config);
     $this->processPattern(function ($value, $key) {
         return $value === NULL;
     }, function ($value, $key) use($user) {
         return $user->isAllowed('WebContent', 'Edit');
     });
 }
开发者ID:zaxxx,项目名称:zaxcms,代码行数:9,代码来源:ArticleConfig.php


示例11: getDefaultQuota

 public function getDefaultQuota(Nette\Security\User $user)
 {
     $quota = '100G';
     if ($user->isInRole('SO') || $user->isInRole('ZSO') || $user->isInRole('VV')) {
         $quota = '3T';
     }
     $quotaNumeric = ByteHelper::humanToBytes($quota);
     return $quotaNumeric;
 }
开发者ID:HKFree,项目名称:NAS,代码行数:9,代码来源:StorageManager.php


示例12: processForm

 /**
  * @param \Nette\Application\UI\Form $form
  */
 public function processForm(Form $form)
 {
     $values = $form->values;
     $event = $this->event ? $this->event : new Entity\Event($this->securityUser->getIdentity());
     $event->name = $values->name;
     $event->date = DateTime::from($values->date);
     $event->place = $values->place;
     $event->note = $values->note;
     $this->eventFacade->save($event);
 }
开发者ID:Kotys,项目名称:eventor.io,代码行数:13,代码来源:SetEventForm.php


示例13: checkLoggedIn

 protected function checkLoggedIn($element)
 {
     if ($element->hasAnnotation('loggedIn')) {
         return $element->getAnnotation('loggedIn') == $this->user->isLoggedIn();
     }
     return true;
 }
开发者ID:davefu,项目名称:PermissionChecker,代码行数:7,代码来源:AnnotationPermissionChecker.php


示例14: formSucceeded

 /**
  * Callback for Account Settings Form onSuccess event.
  * @param Form      $form
  * @param ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     if (!$this->userManager->checkPassword($this->user->getId(), $values->current)) {
         $form->addError("Invalid current password");
     }
     $this->userManager->setNewPassword($this->user->getId(), $values->new);
 }
开发者ID:martinmayer,项目名称:notejam,代码行数:12,代码来源:AccountSettingsFormFactory.php


示例15: __invoke

 /**
  * @return mixed
  */
 public function __invoke()
 {
     if ($this->user->isLoggedIn()) {
         return $this->user->getId();
     }
     return NULL;
 }
开发者ID:darkphoenixff4,项目名称:DoctrineBehaviors,代码行数:10,代码来源:UserCallable.php


示例16: addItem

 /**
  * Add menu item
  * @param string $title Text in anchor
  * @param string $module destination module
  * @param string $presenter destination presenter
  * @param string $action destination action
  * @param string $auth resource for authorizator
  * @param boolean $clickable is anchor clickable?
  * @return void
  */
 public function addItem($title, $module, $presenter, $action, $auth, $clickable = true)
 {
     if ($this->user->isAllowed($auth, "view")) {
         $this->items[] = array("title" => $title, "module" => $module, "presenter" => $presenter, "action" => $action, "clickable" => $clickable);
     }
     return;
 }
开发者ID:OCC2,项目名称:occ2pacs,代码行数:17,代码来源:LeftMenu.php


示例17: formSucceeded

 /**
  * Callback for SignInForm onSuccess event.
  * @param Form      $form
  * @param ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     try {
         $this->user->login($values->email, $values->password);
     } catch (Nette\Security\AuthenticationException $e) {
         $form->addError($e->getMessage());
     }
 }
开发者ID:martinmayer,项目名称:notejam,代码行数:13,代码来源:SignInFormFactory.php


示例18: extractRoles

 private function extractRoles()
 {
     $userRoles = $this->user->getRoles();
     if ($this->roleHierarchy) {
         return $this->roleHierarchy->getReachableRoles($userRoles);
     }
     return $userRoles;
 }
开发者ID:zycon42,项目名称:security,代码行数:8,代码来源:ExpressionEvaluator.php


示例19: createComponentShipmentForm

 public function createComponentShipmentForm()
 {
     $form = $this->shipmentFormFactory->create($this->currentCartService->getCurrentCart()->getShipment(), $this->user->isLoggedIn() ? $this->user->getIdentity() : null);
     $form->onSuccess[] = function (ShipmentForm $form) {
         $this->updateShipment($form);
     };
     return $form;
 }
开发者ID:shophp,项目名称:shophp,代码行数:8,代码来源:ShipmentPresenter.php


示例20: startup

 protected function startup()
 {
     parent::startup();
     if (!$this->user->isLoggedIn()) {
         $this->flashMessage('To enter the section please log in.');
         $this->redirect(':Front:Home:Homepage:');
     }
 }
开发者ID:shophp,项目名称:shophp,代码行数:8,代码来源:BasePresenter.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Utils\Arrays类代码示例发布时间:2022-05-23
下一篇:
PHP Security\Passwords类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap