mirror of
https://github.com/friendica/friendica
synced 2024-12-23 04:40:15 +00:00
Changed:
- added missing type-hints
This commit is contained in:
parent
ed6a537dc5
commit
01632b11c7
1 changed files with 9 additions and 9 deletions
|
@ -32,12 +32,12 @@ use PragmaRX\Random\Random;
|
||||||
*/
|
*/
|
||||||
class AppSpecificPassword
|
class AppSpecificPassword
|
||||||
{
|
{
|
||||||
public static function countForUser($uid)
|
public static function countForUser(int $uid)
|
||||||
{
|
{
|
||||||
return DBA::count('2fa_app_specific_password', ['uid' => $uid]);
|
return DBA::count('2fa_app_specific_password', ['uid' => $uid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function checkDuplicateForUser($uid, $description)
|
public static function checkDuplicateForUser(int $uid, string $description): bool
|
||||||
{
|
{
|
||||||
return DBA::exists('2fa_app_specific_password', ['uid' => $uid, 'description' => $description]);
|
return DBA::exists('2fa_app_specific_password', ['uid' => $uid, 'description' => $description]);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class AppSpecificPassword
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function authenticateUser($uid, $plaintextPassword)
|
public static function authenticateUser(int $uid, string $plaintextPassword): bool
|
||||||
{
|
{
|
||||||
$appSpecificPasswords = self::getListForUser($uid);
|
$appSpecificPasswords = self::getListForUser($uid);
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class AppSpecificPassword
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function getListForUser($uid)
|
public static function getListForUser(int $uid): array
|
||||||
{
|
{
|
||||||
$appSpecificPasswordsStmt = DBA::select('2fa_app_specific_password', ['id', 'description', 'hashed_password', 'last_used'], ['uid' => $uid]);
|
$appSpecificPasswordsStmt = DBA::select('2fa_app_specific_password', ['id', 'description', 'hashed_password', 'last_used'], ['uid' => $uid]);
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ class AppSpecificPassword
|
||||||
* @return array The new app-specific password data structure with the plaintext password added
|
* @return array The new app-specific password data structure with the plaintext password added
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function generateForUser(int $uid, $description)
|
public static function generateForUser(int $uid, string $description): array
|
||||||
{
|
{
|
||||||
$Random = (new Random())->size(40);
|
$Random = (new Random())->size(40);
|
||||||
|
|
||||||
|
@ -111,10 +111,10 @@ class AppSpecificPassword
|
||||||
$generated = DateTimeFormat::utcNow();
|
$generated = DateTimeFormat::utcNow();
|
||||||
|
|
||||||
$fields = [
|
$fields = [
|
||||||
'uid' => $uid,
|
'uid' => $uid,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'hashed_password' => User::hashPassword($plaintextPassword),
|
'hashed_password' => User::hashPassword($plaintextPassword),
|
||||||
'generated' => $generated,
|
'generated' => $generated,
|
||||||
];
|
];
|
||||||
|
|
||||||
DBA::insert('2fa_app_specific_password', $fields);
|
DBA::insert('2fa_app_specific_password', $fields);
|
||||||
|
@ -125,7 +125,7 @@ class AppSpecificPassword
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function update($appSpecificPasswordId, $fields)
|
private static function update(int $appSpecificPasswordId, array $fields)
|
||||||
{
|
{
|
||||||
return DBA::update('2fa_app_specific_password', $fields, ['id' => $appSpecificPasswordId]);
|
return DBA::update('2fa_app_specific_password', $fields, ['id' => $appSpecificPasswordId]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue