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 4020 of file grima-lib.php.
◆ addToDB()
Definition at line 4132 of file grima-lib.php.
4134 $query =
$db->prepare(
'INSERT INTO users( username, password, institution, isAdmin ) VALUES (:username, :password, :institution, :isAdmin)' );
4136 $errorCode =
$db->errorCode();
4137 $errorInfo =
$db->errorInfo();
4138 throw new Exception(
4139 "Could not even prepare to insert into user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4142 $success = $query->execute( array(
4143 'username' => $this[
'username'],
4145 'institution' => $this[
'institution'],
4146 'isAdmin' => $this[
'isAdmin'],
4149 $errorCode = $query->errorCode();
4150 $errorInfo = $query->errorInfo();
4151 throw new Exception(
4152 "Could not insert into user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
◆ deleteFromDB()
| GrimaUser::deleteFromDB |
( |
|
) |
|
Definition at line 4182 of file grima-lib.php.
4184 $query =
$db->prepare(
'DELETE FROM users WHERE username=:username AND institution=:institution' );
4186 $errorCode =
$db->errorCode();
4187 $errorInfo =
$db->errorInfo();
4188 throw new Exception(
4189 "Could not even prepare to delete from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4192 $success = $query->execute( array(
4193 'username' => $this[
'username'],
4194 'institution' => $this[
'institution'],
4197 $errorCode = $query->errorCode();
4198 $errorInfo = $query->errorInfo();
4199 throw new Exception(
4200 "Could not delete from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
◆ FromArray()
| static GrimaUser::FromArray |
( |
|
$data |
) |
|
|
static |
◆ GetCurrentUser()
| static GrimaUser::GetCurrentUser |
( |
|
) |
|
|
static |
◆ LogoutCurrentUser()
| static GrimaUser::LogoutCurrentUser |
( |
|
) |
|
|
static |
◆ LookupUser()
| static GrimaUser::LookupUser |
( |
|
$username, |
|
|
|
$institution = '', |
|
|
|
$password = FALSE |
|
) |
|
|
|
static |
Definition at line 4029 of file grima-lib.php.
References FromArray().
Referenced by SetCurrentUser().
4030 $db = self::getDb();
4031 $query =
$db->prepare(
4033 'FROM institutions NATURAL JOIN users '.
4034 'WHERE institution=:institution '.
4035 'AND username=:username'
4037 $success = $query->execute( array(
4038 'institution' => $institution,
4039 'username' => $username,
4042 $row = $query->fetch(PDO::FETCH_ASSOC);
4043 if ($row===
false)
return false;
4045 if ( ($password !== FALSE) && ($user[
'password']!=
'') ) {
4046 if ( !password_verify( $password, $user[
'password'] ) )
return false;
4047 if ( password_needs_rehash( $user[
'password'], $user->getPasswordAlgorithm() ) ) {
4048 $user[
'password'] = $password;
4052 unset( $user[
'password'] );
4055 $errorCode = $query->errorCode();
4056 $errorInfo = $query->errorInfo();
4057 throw new Exception(
4058 "Could not select from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
◆ RenameUser()
| static GrimaUser::RenameUser |
( |
|
$username, |
|
|
|
$institution, |
|
|
|
$newusername |
|
) |
|
|
|
static |
Definition at line 4063 of file grima-lib.php.
4064 $db = self::getDb();
4065 $query =
$db->prepare(
4067 'SET username=:newusername ' .
4068 'WHERE institution=:institution '.
4069 'AND username=:username'
4071 $success = $query->execute( array(
4072 'institution' => $institution,
4073 'username' => $username,
4074 'newusername' => $newusername,
4079 $errorCode = $query->errorCode();
4080 $errorInfo = $query->errorInfo();
4081 throw new Exception(
4082 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
◆ ResetPassword()
| static GrimaUser::ResetPassword |
( |
|
$username, |
|
|
|
$institution, |
|
|
|
$password |
|
) |
|
|
|
static |
Definition at line 4087 of file grima-lib.php.
4088 $db = self::getDb();
4089 $query =
$db->prepare(
4091 'SET password=:password ' .
4092 'WHERE institution=:institution '.
4093 'AND username=:username'
4095 $passwordHash = password_hash( $password, self::getPasswordAlgorithm() );
4096 $success = $query->execute( array(
4097 'institution' => $institution,
4098 'username' => $username,
4099 'password' => $passwordHash,
4104 $errorCode = $query->errorCode();
4105 $errorInfo = $query->errorInfo();
4106 throw new Exception(
4107 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
◆ SetCurrentUser()
| static GrimaUser::SetCurrentUser |
( |
|
$username, |
|
|
|
$password, |
|
|
|
$institution = '' |
|
) |
|
|
|
static |
Definition at line 4117 of file grima-lib.php.
References $grima, and LookupUser().
4120 if ( $user !==
false ) {
4121 $grima->session_save($user);
static LookupUser($username, $institution='', $password=FALSE)
◆ updateDB()
Definition at line 4157 of file grima-lib.php.
4159 $query =
$db->prepare(
'UPDATE users SET isAdmin=:isAdmin, password=:password WHERE username=:username AND institution=:institution' );
4161 $errorCode =
$db->errorCode();
4162 $errorInfo =
$db->errorInfo();
4163 throw new Exception(
4164 "Could not even prepare to update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4167 $success = $query->execute( array(
4168 'username' => $this[
'username'],
4170 'institution' => $this[
'institution'],
4171 'isAdmin' => $this[
'isAdmin'],
4174 $errorCode = $query->errorCode();
4175 $errorInfo = $query->errorInfo();
4176 throw new Exception(
4177 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
The documentation for this class was generated from the following file: