當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sentinel::userExists方法代碼示例

本文整理匯總了PHP中Sentinel::userExists方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sentinel::userExists方法的具體用法?PHP Sentinel::userExists怎麽用?PHP Sentinel::userExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sentinel的用法示例。


在下文中一共展示了Sentinel::userExists方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: unset

 $password2 = $_POST['password2'];
 $roles = $_POST['roles'];
 $type = $_POST['add-type'];
 unset($_POST['csrf_token']);
 unset($_POST['action']);
 unset($_POST['username']);
 unset($_POST['password']);
 unset($_POST['password2']);
 unset($_POST['roles']);
 unset($_POST['add-type']);
 $logfiles = $_POST;
 $errors = array();
 if (empty($username)) {
     $errors['username'] = __('Username is required');
 } else {
     if ($type === 'add' && Sentinel::userExists($username)) {
         $errors['username'] = sprintf(__('User %s already exists'), '<code>' . $username . '</code>');
     }
 }
 if ($type === 'edit' && !empty($password) || $type === 'add') {
     if (mb_strlen($password) < 6) {
         $errors['password'] = __('Password must contain at least 6 chars');
     }
     if ($password !== $password2) {
         $errors['password2'] = __('Password confirmation is not the same');
     }
 }
 if (count($errors) === 0) {
     if (empty($password)) {
         $password = null;
     }
開發者ID:expressive-analytics,項目名稱:docker-dt-standard.php,代碼行數:31,代碼來源:users.pml.php

示例2: _h

        ?>
"></div></div></div><br><br><input type="submit" class="btn btn-large btn-success" value="<?php 
        _h('Enable authentication');
        ?>
"></form><?php 
    }
    ?>
</div><div class="tab-pane" id="passwordtab"><?php 
    if (Sentinel::isAuthSet()) {
        ?>
<br><h4><?php 
        _e('Please fill an existing username and a new password');
        ?>
</h4><?php 
        if (@$_POST['action'] === 'passwordtab') {
            if (!Sentinel::userExists($_POST['username'])) {
                echo '<div class="alert alert-danger" role="alert">' . sprintf(__('User %s does not exist!'), '<code>' . $_POST['username'] . '</code>') . '</div>';
            } else {
                if ($_POST['password'] !== $_POST['password2']) {
                    echo '<div class="alert alert-danger" role="alert">' . __('Password confirmation is not the same') . '</div>';
                } else {
                    if (mb_strlen($_POST['password']) < 6) {
                        echo '<div class="alert alert-danger" role="alert">' . __('Password must contain at least 6 chars') . '</div>';
                    } else {
                        Sentinel::setUser($_POST['username'], $_POST['password']);
                        Sentinel::save();
                        echo '<div class="alert alert-success" role="alert">' . sprintf(__('Password has been updated for user %s!'), '<code>' . $_POST['username'] . '</code>') . '</div>';
                    }
                }
            }
        }
開發者ID:abhijith444,項目名稱:enroll,代碼行數:31,代碼來源:test.php


注:本文中的Sentinel::userExists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。