Interface to the GrimaDB database to check password and get institution's apikey.
More...
Interface to the GrimaDB database to check password and get institution's apikey.
Definition at line 3233 of file grima-lib.php.
◆ addToDB()
Definition at line 3347 of file grima-lib.php.
References GrimaDB\$db, GrimaDB\getDb(), and GrimaDB\getPasswordAlgorithm().
3349 $query =
$db->prepare(
'INSERT INTO users( username, password, institution, isAdmin ) VALUES (:username, :password, :institution, :isAdmin)' );
3351 $errorCode =
$db->errorCode();
3352 $errorInfo =
$db->errorInfo();
3353 throw new Exception(
3354 "Could not even prepare to insert into user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3357 $success = $query->execute( array(
3358 'username' => $this[
'username'],
3360 'institution' => $this[
'institution'],
3361 'isAdmin' => $this[
'isAdmin'],
3364 $errorCode = $query->errorCode();
3365 $errorInfo = $query->errorInfo();
3366 throw new Exception(
3367 "Could not insert into user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
◆ deleteFromDB()
| GrimaUser::deleteFromDB |
( |
| ) |
|
Definition at line 3397 of file grima-lib.php.
References GrimaDB\$db, and GrimaDB\getDb().
3399 $query =
$db->prepare(
'DELETE FROM users WHERE username=:username AND institution=:institution' );
3401 $errorCode =
$db->errorCode();
3402 $errorInfo =
$db->errorInfo();
3403 throw new Exception(
3404 "Could not even prepare to delete from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3407 $success = $query->execute( array(
3408 'username' => $this[
'username'],
3409 'institution' => $this[
'institution'],
3412 $errorCode = $query->errorCode();
3413 $errorInfo = $query->errorInfo();
3414 throw new Exception(
3415 "Could not delete from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
◆ FromArray()
| static GrimaUser::FromArray |
( |
|
$data | ) |
|
|
static |
Definition at line 3234 of file grima-lib.php.
Referenced by GetCurrentUser(), and LookupUser().
3236 foreach ( $data as $key => $val ) {
Interface to the GrimaDB database to check password and get institution's apikey. ...
◆ GetCurrentUser()
| static GrimaUser::GetCurrentUser |
( |
| ) |
|
|
static |
◆ LookupUser()
| static GrimaUser::LookupUser |
( |
|
$username, |
|
|
|
$institution = '', |
|
|
|
$password = FALSE |
|
) |
| |
|
static |
Definition at line 3242 of file grima-lib.php.
References GrimaDB\$db, and FromArray().
Referenced by SetCurrentUser().
3243 $db = self::getDb();
3244 $query =
$db->prepare(
3246 'FROM institutions NATURAL JOIN users '.
3247 'WHERE institution=:institution '.
3248 'AND username=:username' 3250 $success = $query->execute( array(
3251 'institution' => $institution,
3252 'username' => $username,
3255 $row = $query->fetch(PDO::FETCH_ASSOC);
3256 if ($row===
false)
return false;
3258 if ( ($password !== FALSE) && ($user[
'password']!=
'') ) {
3259 if ( !password_verify( $password, $user[
'password'] ) )
return false;
3260 if ( password_needs_rehash( $user[
'password'], $user->getPasswordAlgorithm() ) ) {
3261 $user[
'password'] = $password;
3265 unset( $user[
'password'] );
3268 $errorCode = $query->errorCode();
3269 $errorInfo = $query->errorInfo();
3270 throw new Exception(
3271 "Could not select from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
◆ RenameUser()
| static GrimaUser::RenameUser |
( |
|
$username, |
|
|
|
$institution, |
|
|
|
$newusername |
|
) |
| |
|
static |
Definition at line 3276 of file grima-lib.php.
References GrimaDB\$db.
3277 $db = self::getDb();
3278 $query =
$db->prepare(
3280 'SET username=:newusername ' .
3281 'WHERE institution=:institution '.
3282 'AND username=:username' 3284 $success = $query->execute( array(
3285 'institution' => $institution,
3286 'username' => $username,
3287 'newusername' => $newusername,
3292 $errorCode = $query->errorCode();
3293 $errorInfo = $query->errorInfo();
3294 throw new Exception(
3295 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
◆ ResetPassword()
| static GrimaUser::ResetPassword |
( |
|
$username, |
|
|
|
$institution, |
|
|
|
$password |
|
) |
| |
|
static |
Definition at line 3300 of file grima-lib.php.
References GrimaDB\$db.
3301 $db = self::getDb();
3302 $query =
$db->prepare(
3304 'SET password=:password ' .
3305 'WHERE institution=:institution '.
3306 'AND username=:username' 3308 $passwordHash = password_hash( $password, self::getPasswordAlgorithm() );
3309 $success = $query->execute( array(
3310 'institution' => $institution,
3311 'username' => $username,
3312 'password' => $passwordHash,
3317 $errorCode = $query->errorCode();
3318 $errorInfo = $query->errorInfo();
3319 throw new Exception(
3320 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
◆ SetCurrentUser()
| static GrimaUser::SetCurrentUser |
( |
|
$username, |
|
|
|
$password, |
|
|
|
$institution = '' |
|
) |
| |
|
static |
Definition at line 3333 of file grima-lib.php.
References $grima, and LookupUser().
3336 if ( $user !==
false ) {
3337 if (isset($_SESSION)) {
3338 session_write_close();
3341 $grima->session_save($user);
static LookupUser($username, $institution='', $password=FALSE)
◆ updateDB()
Definition at line 3372 of file grima-lib.php.
References GrimaDB\$db, GrimaDB\getDb(), and GrimaDB\getPasswordAlgorithm().
3374 $query =
$db->prepare(
'UPDATE users SET isAdmin=:isAdmin, password=:password WHERE username=:username AND institution=:institution' );
3376 $errorCode =
$db->errorCode();
3377 $errorInfo =
$db->errorInfo();
3378 throw new Exception(
3379 "Could not even prepare to update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3382 $success = $query->execute( array(
3383 'username' => $this[
'username'],
3385 'institution' => $this[
'institution'],
3386 'isAdmin' => $this[
'isAdmin'],
3389 $errorCode = $query->errorCode();
3390 $errorInfo = $query->errorInfo();
3391 throw new Exception(
3392 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
The documentation for this class was generated from the following file: