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


PHP Security::has_default_admin方法代码示例

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


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

示例1: testCheckDefaultAdmin

 public function testCheckDefaultAdmin()
 {
     $this->assertTrue(Security::has_default_admin());
     $this->assertTrue(Security::check_default_admin('admin', 'password'), 'Succeeds with correct username and password');
     $this->assertFalse(Security::check_default_admin('wronguser', 'password'), 'Fails with incorrect username');
     $this->assertFalse(Security::check_default_admin('admin', 'wrongpassword'), 'Fails with incorrect password');
 }
开发者ID:nickbooties,项目名称:silverstripe-framework,代码行数:7,代码来源:SecurityDefaultAdminTest.php

示例2: show

 public function show()
 {
     if ($member = Member::currentUser()) {
         if (!$member->Email || Security::has_default_admin()) {
             return true;
         }
     }
     return false;
 }
开发者ID:helpfulrobot,项目名称:stnvh-silverstripe-infoboxes,代码行数:9,代码来源:InfoBox_pass.php

示例3: testCheckDefaultAdmin

 public function testCheckDefaultAdmin()
 {
     if (Security::has_default_admin()) {
         $this->markTestSkipped('Default admin present. There\'s no way to inspect default admin state, ' . 'so we don\'t override existing settings');
     }
     Security::setDefaultAdmin('admin', 'password');
     $this->assertTrue(Security::has_default_admin());
     $this->assertTrue(Security::check_default_admin('admin', 'password'), 'Succeeds with correct username and password');
     $this->assertFalse(Security::check_default_admin('wronguser', 'password'), 'Fails with incorrect username');
     $this->assertFalse(Security::check_default_admin('admin', 'wrongpassword'), 'Fails with incorrect password');
     Security::setDefaultAdmin(null, null);
 }
开发者ID:fanggu,项目名称:loveyourwater_ss_v3.1.6,代码行数:12,代码来源:SecurityDefaultAdminTest.php

示例4: default_admin

 /**
  * Get the default admin record if it exists, or creates it otherwise if enabled
  *
  * @return Member
  */
 public static function default_admin()
 {
     // Check if set
     if (!Security::has_default_admin()) {
         return null;
     }
     // Find or create ADMIN group
     singleton('Group')->requireDefaultRecords();
     $adminGroup = Permission::get_groups_by_permission('ADMIN')->First();
     // Find member
     $admin = Member::get()->filter('Email', Security::default_admin_username())->first();
     if (!$admin) {
         // 'Password' is not set to avoid creating
         // persistent logins in the database. See Security::setDefaultAdmin().
         // Set 'Email' to identify this as the default admin
         $admin = Member::create();
         $admin->FirstName = _t('Member.DefaultAdminFirstname', 'Default Admin');
         $admin->Email = Security::default_admin_username();
         $admin->write();
     }
     // Ensure this user is in the admin group
     if (!$admin->inGroup($adminGroup)) {
         $admin->Groups()->add($adminGroup);
     }
     return $admin;
 }
开发者ID:8secs,项目名称:cocina,代码行数:31,代码来源:Member.php

示例5: reset

<?php

/**
 * User: Julian Scheuchenzuber <js@lvl51.de>
 * Date: 22.10.15
 * Time: 12:12
 */
if (isset($GLOBALS['_DEFAULT_ADMINS'])) {
    // Reset pointer and fetch data of first record
    reset($GLOBALS['_DEFAULT_ADMINS']);
    $email = key($GLOBALS['_DEFAULT_ADMINS']);
    $pw = $GLOBALS['_DEFAULT_ADMINS'][$email];
    // Set default admin if not exists
    if (!Security::has_default_admin()) {
        Security::setDefaultAdmin($email, $pw);
    }
}
开发者ID:helpfulrobot,项目名称:level51-more-admins,代码行数:17,代码来源:_config.php

示例6: isDefaultAdmin

 /**
  * Check if this user is the currently configured default admin
  *
  * @return bool
  */
 public function isDefaultAdmin()
 {
     return Security::has_default_admin() && $this->Email === Security::default_admin_username();
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:9,代码来源:Member.php

示例7: loginAsAdmin

 /**
  * Ensures we have permissions to manipulate pages (gets around access issues with global state). Unfortunately, the
  * creation of a default admin account below is necessary because SilverStripe will reference global state via
  * Member::currentUser() and the only surefire way around this is to login as a default admin with full access.
  *
  * CAUTION: Since migrations can only be run from the command line, it's assumed that if you're accessing this, then
  * you're already an admin or you've got an incorrectly configured site!
  *
  * TODO: This should be removed soon.
  *
  * @deprecated  Use ::whileAdmin() instead.
  */
 protected static function loginAsAdmin()
 {
     Deprecation::notice('0', 'Use ::whileAdmin() instead. This method will be removed soon.');
     if (!Member::currentUserID()) {
         // See if a default admin is setup yet.
         if (!Security::has_default_admin()) {
             // Generate a randomized user/pass and use that as the default administrator just for this session.
             $user = substr(str_shuffle(sha1("u" . microtime())), 0, 20);
             $pass = substr(str_shuffle(sha1("p" . microtime())), 0, 20);
             Security::setDefaultAdmin($user, $pass);
         }
         $admin = Member::default_admin();
         if (!$admin) {
             throw new MigrationException("Cannot login: No default administrator found.");
         }
         Session::start();
         Session::set("loggedInAs", $admin->ID);
     }
 }
开发者ID:patricknelson,项目名称:silverstripe-migrations,代码行数:31,代码来源:Migration.php


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