Open Journal Systems  3.3.0
Validation Class Reference

Static Public Member Functions

static canAdminister ($administeredUserId, $administratorUserId)
 
static checkCredentials ($username, $password)
 
static encryptCredentials ($username, $password, $encryption=false, $legacy=false)
 
static generatePassword ($length=null)
 
static generatePasswordResetHash ($userId, $expiry=null)
 
static isAuthorized ($roleId, $contextId=0)
 
static isLoggedIn ()
 
static isLoggedIn ()
 
static isLoggedInAs ()
 
static isSiteAdmin ()
 
static login ($username, $password, &$reason, $remember=false)
 
static logout ()
 
static redirectLogin ($message=null)
 
static registerUserSession ($user, &$reason, $remember=false)
 
static setIsLoggedIn ($isLoggedIn)
 
static suggestUsername ($givenName, $familyName=null)
 
static verifyPassword ($username, $password, $hash, &$rehash)
 
static verifyPasswordResetHash ($userId, $hash)
 

Static Public Attributes

static $_isLoggedIn = false
 

Detailed Description

Class providing user validation/authentication operations.

Mock implementation of the Validation class for the PKPPageRouterTest.

See also
PKPPageRouterTest

Definition at line 16 of file Validation.inc.php.

Member Function Documentation

◆ canAdminister()

static Validation::canAdminister (   $administeredUserId,
  $administratorUserId 
)
static

Check whether a user is allowed to administer another user.

Parameters
$administeredUserIdint User ID of user to potentially administer
$administratorUserIdint User ID of user who wants to do the administrating
Returns
boolean True IFF the administration operation is permitted

Definition at line 410 of file Validation.inc.php.

References DAORegistry\getDAO().

Referenced by UserGridHandler\disableUser(), UserGridHandler\editDisableUser(), UserGridHandler\editUser(), UserGridRow\initialize(), ReviewerGridRow\initialize(), StageParticipantGridRow\initialize(), UserGridHandler\mergeUsers(), UserGridHandler\removeUser(), LoginHandler\signInAsUser(), UserGridHandler\updateUser(), and UserGridHandler\updateUserRoles().

◆ checkCredentials()

static Validation::checkCredentials (   $username,
  $password 
)
static

Check if a user's credentials are valid.

Parameters
$usernamestring username
$passwordstring unencrypted password
Returns
boolean

Definition at line 188 of file Validation.inc.php.

References DAORegistry\getDAO(), and verifyPassword().

Referenced by LoginChangePasswordForm\__construct(), and ChangePasswordForm\__construct().

◆ encryptCredentials()

static Validation::encryptCredentials (   $username,
  $password,
  $encryption = false,
  $legacy = false 
)
static

Encrypt user passwords for database storage. The username is used as a unique salt to make dictionary attacks against a compromised database more difficult.

Parameters
$usernamestring username (kept for backwards compatibility)
$passwordstring unencrypted password
$encryptionstring optional encryption algorithm to use, defaulting to the value from the site configuration
$legacyboolean if true, use legacy hashing technique for backwards compatibility
Returns
string encrypted password

Definition at line 255 of file Validation.inc.php.

References Config\getVar().

Referenced by PKPInstall\createData(), LoginChangePasswordForm\execute(), CreateReviewerForm\execute(), ChangePasswordForm\execute(), RegistrationForm\execute(), UserDetailsForm\execute(), UserXmlPKPUserFilter\importUserPasswordValidation(), LoginHandler\resetPassword(), and verifyPassword().

◆ generatePassword()

static Validation::generatePassword (   $length = null)
static

Generate a random password. Assumes the random number generator has already been seeded.

Parameters
$lengthint the length of the password to generate (default is site minimum)
Returns
string

Definition at line 283 of file Validation.inc.php.

References DAORegistry\getDAO().

Referenced by AccessKeyManager\createKey(), LoginChangePasswordForm\execute(), CreateReviewerForm\execute(), ChangePasswordForm\execute(), UserDetailsForm\execute(), UserXmlPKPUserFilter\importUserPasswordValidation(), and LoginHandler\resetPassword().

◆ generatePasswordResetHash()

static Validation::generatePasswordResetHash (   $userId,
  $expiry = null 
)
static

Generate a hash value to use for confirmation to reset a password.

Parameters
$userIdint
$expiryint timestamp when hash expires, defaults to CURRENT_TIME + RESET_SECONDS
Returns
string (boolean false if user is invalid)

Definition at line 305 of file Validation.inc.php.

References DAORegistry\getDAO(), and Config\getVar().

Referenced by ReviewReminderForm\execute(), ThankReviewerForm\initData(), ReviewReminderForm\initData(), LoginHandler\requestResetPassword(), and ReviewReminder\sendReminder().

◆ isAuthorized()

static Validation::isAuthorized (   $roleId,
  $contextId = 0 
)
static

Check if a user is authorized to access the specified role in the specified context.

Parameters
$roleIdint
$contextIdoptional (e.g., for global site admin role), the ID of the context
Returns
boolean

Definition at line 225 of file Validation.inc.php.

References PKPApplication\get(), DAORegistry\getDAO(), and SessionManager\getManager().

Referenced by isSiteAdmin().

◆ isLoggedIn() [1/2]

static Validation::isLoggedIn ( )
static

Definition at line 20 of file MockValidation.inc.php.

References $_isLoggedIn.

◆ isLoggedIn() [2/2]

◆ isLoggedInAs()

◆ isSiteAdmin()

static Validation::isSiteAdmin ( )
static

Shortcut for checking authorization as site admin.

Returns
boolean

Definition at line 400 of file Validation.inc.php.

References isAuthorized().

Referenced by CounterReportPlugin\display(), IndexHandler\index(), LanguageGridRow\initialize(), and PluginGalleryGridHandler\viewPlugin().

◆ login()

static Validation::login (   $username,
  $password,
$reason,
  $remember = false 
)
static

Authenticate user credentials and mark the user as logged in in the current session.

Parameters
$usernamestring
$passwordstring unencrypted password
$reasonstring reference to string to receive the reason an account was disabled; null otherwise
$rememberboolean remember a user's session past the current browser session
Returns
User the User associated with the login credentials, or false if the credentials are invalid

Definition at line 26 of file Validation.inc.php.

References DAORegistry\getDAO(), registerUserSession(), and verifyPassword().

Referenced by RegistrationHandler\register(), LoginHandler\savePassword(), and LoginHandler\signIn().

◆ logout()

static Validation::logout ( )
static

Mark the user as logged out in the current session.

Returns
boolean

Definition at line 146 of file Validation.inc.php.

References DAORegistry\getDAO(), and SessionManager\getManager().

Referenced by LoginHandler\signIn(), and LoginHandler\signOut().

◆ redirectLogin()

static Validation::redirectLogin (   $message = null)
static

Redirect to the login page, appending the current URL as the source.

Parameters
$messagestring Optional name of locale key to add to login page

Definition at line 168 of file Validation.inc.php.

References PKPApplication\get().

Referenced by PKPUserHandler\authorizationDenied(), CounterReportPlugin\display(), PKPPageRouter\handleAuthorizationFailure(), PaymentHandler\pay(), IssueHandler\userCanViewGalley(), ArticleHandler\userCanViewGalley(), and PKPHandler\validate().

◆ registerUserSession()

static Validation::registerUserSession (   $user,
$reason,
  $remember = false 
)
static

Mark the user as logged in in the current session.

Parameters
$userUser user to register in the session
$reasonstring reference to string to receive the reason an account was disabled; null otherwise
$rememberboolean remember a user's session past the current browser session
Returns
mixed User or boolean the User associated with the login credentials, or false if the credentials are invalid

Definition at line 107 of file Validation.inc.php.

References Core\getCurrentDate(), DAORegistry\getDAO(), SessionManager\getManager(), and Config\getVar().

Referenced by ReviewerHandler\_validateAccessKey(), and login().

◆ setIsLoggedIn()

static Validation::setIsLoggedIn (   $isLoggedIn)
static

Definition at line 24 of file MockValidation.inc.php.

References $_isLoggedIn.

Referenced by PKPPageRouterTest\testIsCacheableWithPathinfoSuccess().

◆ suggestUsername()

static Validation::suggestUsername (   $givenName,
  $familyName = null 
)
static

Suggest a username given the first and last names.

Parameters
$givenNamestring
$familyNamestring
Returns
string

Definition at line 359 of file Validation.inc.php.

References DAORegistry\getDAO(), PKPString\regexp_replace(), and PKPString\substr().

Referenced by UserApiHandler\suggestUsername().

◆ verifyPassword()

static Validation::verifyPassword (   $username,
  $password,
  $hash,
$rehash 
)
static

Verify if the input password is correct

Parameters
string$usernamethe string username
string$passwordthe plaintext password
string$hashthe password hash from the database
string&$rehashif password needs rehash, this variable is used
Returns
boolean

Definition at line 84 of file Validation.inc.php.

References encryptCredentials().

Referenced by checkCredentials(), and login().

◆ verifyPasswordResetHash()

static Validation::verifyPasswordResetHash (   $userId,
  $hash 
)
static

Check if provided password reset hash is valid.

Parameters
$userIdint
$hashstring
Returns
boolean

Definition at line 341 of file Validation.inc.php.

Referenced by LoginHandler\resetPassword().

Field Documentation

◆ $_isLoggedIn

Validation::$_isLoggedIn = false
static

Definition at line 18 of file MockValidation.inc.php.

Referenced by isLoggedIn(), and setIsLoggedIn().


The documentation for this class was generated from the following files: