本文整理汇总了PHP中OCP\User::checkPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP User::checkPassword方法的具体用法?PHP User::checkPassword怎么用?PHP User::checkPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\User
的用法示例。
在下文中一共展示了User::checkPassword方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkPassword
/**
* @brief Checks the password of a user.
* @param string $userName ownCloud user name whose password will be checked.
* @param string $password ownCloud password.
* @return bool True if the password is correct, false otherwise.
*
*/
private static function checkPassword($userName, $password)
{
// Check password normally
if (\OCP\User::checkPassword($userName, $password) != false) {
return true;
}
return false;
}
示例2: isset
<?php
/**
* Copyright (c) 2013, Bjoern Schiessle <schiessle@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*
* check migration status
*/
use OCA\Encryption\Util;
\OCP\JSON::checkAppEnabled('files_encryption');
$loginname = isset($_POST['user']) ? $_POST['user'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
$migrationStatus = Util::MIGRATION_COMPLETED;
if ($loginname !== '' && $password !== '') {
$username = \OCP\User::checkPassword($loginname, $password);
if ($username) {
$util = new Util(new \OC\Files\View('/'), $username);
$migrationStatus = $util->getMigrationStatus();
}
}
\OCP\JSON::success(array('data' => array('migrationStatus' => $migrationStatus)));
示例3: testCheckPasswordPublicAPIWrongUser
public function testCheckPasswordPublicAPIWrongUser()
{
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
$backend = new UserLDAP($access, $this->getMock('\\OCP\\IConfig'));
\OC_User::useBackend($backend);
$result = \OCP\User::checkPassword('mallory', 'evil');
$this->assertFalse($result);
}
示例4: testCheckPasswordPublicAPI
public function testCheckPasswordPublicAPI()
{
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
$backend = new UserLDAP($access);
\OC_User::useBackend($backend);
$result = \OCP\User::checkPassword('roland', 'dt19');
$this->assertEquals('gunslinger', $result);
$result = \OCP\User::checkPassword('roland', 'wrong');
$this->assertFalse($result);
$result = \OCP\User::checkPassword('mallory', 'evil');
$this->assertFalse($result);
}
示例5:
*
*/
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('files_encryption');
\OCP\JSON::callCheck();
$l = \OC::$server->getL10N('core');
$return = false;
$errorMessage = $l->t('Could not update the private key password.');
$oldPassword = (string) $_POST['oldPassword'];
$newPassword = (string) $_POST['newPassword'];
$view = new \OC\Files\View('/');
$session = new \OCA\Files_Encryption\Session($view);
$user = \OCP\User::getUser();
$loginName = \OC::$server->getUserSession()->getLoginName();
// check new password
$passwordCorrect = \OCP\User::checkPassword($loginName, $newPassword);
if ($passwordCorrect !== false) {
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
$encryptedKey = \OCA\Files_Encryption\Keymanager::getPrivateKey($view, $user);
$decryptedKey = $encryptedKey ? \OCA\Files_Encryption\Crypt::decryptPrivateKey($encryptedKey, $oldPassword) : false;
if ($decryptedKey) {
$cipher = \OCA\Files_Encryption\Helper::getCipher();
$encryptedKey = \OCA\Files_Encryption\Crypt::symmetricEncryptFileContent($decryptedKey, $newPassword, $cipher);
if ($encryptedKey) {
\OCA\Files_Encryption\Keymanager::setPrivateKey($encryptedKey, $user);
$session->setPrivateKey($decryptedKey);
$return = true;
}
} else {
$result = false;
示例6: checkPassword
/**
* @brief Checks the password of a user. Additionally verifies whether user
* is member of group that is allowed to use Mozilla Sync.
*
* Checks the supplied password for the user. If the LDAP app is also
* active it tries to authenticate against it as well. For this to work the
* User Login Filter in the admin panel needs to be set to something
* like (|(uid=%uid)(mail=$uid)) .
*
* @param string $userName ownCloud user name whose password will be checked.
* @param string $password ownCloud password.
* @return bool True if the password is correct, false otherwise.
*
*/
private static function checkPassword($userName, $password)
{
// NOTE: Since ownCloud 7 authentication apps are loaded automatically
// Check if user is allowed to use Mozilla Sync
if (self::checkUserIsAllowed($userName) === false) {
return false;
}
// Check password normally
if (\OCP\User::checkPassword($userName, $password) != false) {
return true;
}
// Check if the LDAP app is enabled
if (\OCP\App::isEnabled('user_ldap')) {
// Convert user name to email address
$email = self::userNameToEmail($userName);
if ($email === false) {
return false;
}
// Check password with email instead of user name as internal
// ownCloud user name and LDAP user ID are likely not to match
$res = \OCP\User::checkPassword($email, $password) != false;
if ($res === false) {
Utils::writeLog("LDAP password did not match for user " . $userName . " with email address " . $email . ".");
}
return $res;
}
Utils::writeLog("Password did not match for user " . $userName . ".");
return false;
}
示例7: authenticateUser
/**
* @brief Authenticate user by HTTP Basic Authorization user and password
*
* @param string $userHash User hash parameter specified by Url parameter
* @return boolean
*/
public static function authenticateUser($userHash)
{
if (!isset($_SERVER['PHP_AUTH_USER'])) {
return false;
}
// user name parameter and authentication user name doen't match
if ($userHash != $_SERVER['PHP_AUTH_USER']) {
return false;
}
$userId = self::userHashToUserName($userHash);
if ($userId == false) {
return false;
}
return \OCP\User::checkPassword($userId, $_SERVER['PHP_AUTH_PW']);
}