Skip to content

Commit

Permalink
CS
Browse files Browse the repository at this point in the history
  • Loading branch information
dergel committed Mar 14, 2024
1 parent eb74c1b commit 7eb73e5
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/ycom.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static function addTable(string $table_name): void
}

/**
* @return string[]
* @return array<string>
*/
public static function getTables(): array
{
Expand Down
8 changes: 4 additions & 4 deletions lib/ycom_user.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

class rex_ycom_user extends \rex_yform_manager_dataset
class rex_ycom_user extends rex_yform_manager_dataset
{
public string $password = '';
public int $login_tries = 0;

/**
* @return null|rex_ycom_user
* @return rex_ycom_user|null
*/
public static function getMe()
{
Expand Down Expand Up @@ -36,7 +36,7 @@ public function getPassword(): string
}

/**
* @return array|string[]
* @return array|array<string>
*/
public function getGroups(): array
{
Expand All @@ -49,7 +49,7 @@ public function getGroups(): array

/**
* @param array<string|int, mixed> $data
* @return null|rex_ycom_user|rex_yform_manager_dataset
* @return rex_ycom_user|rex_yform_manager_dataset|null
*/
public static function createUserByEmail(array $data)
{
Expand Down
1 change: 0 additions & 1 deletion plugins/auth/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
->setQuery('delete from `' . rex_yform_manager_field::table() . '` where `table_name`="rex_ycom_user" and `type_id`="value" and `type_name`="checkbox" and `name`="termofuse_accepted"', [])
->setQuery('update `rex_config` set `key`="article_id_jump_termsofuse" where `key`="article_id_jump_termofuse" and `namespace`="ycom/auth"', [])
->setQuery('delete from `' . rex_yform_manager_field::table() . '` where `table_name`="rex_ycom_user" and `type_id`="value" and `type_name`="generate_key" and `name`="session_key"');

} catch (rex_sql_exception $e) {
dump($e);
exit;
Expand Down
10 changes: 5 additions & 5 deletions plugins/auth/lib/ycom_auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public static function login(array $params): int

/**
* @param array<string, string> $params
* @return null|false|rex_ycom_user
* @return false|rex_ycom_user|null
*/
public static function loginWithParams($params, ?callable $filter = null)
{
Expand Down Expand Up @@ -428,13 +428,13 @@ public static function checkPassword(string $password, $user_id): bool

public static function setUser(rex_ycom_user $me): void
{
\rex_login::startSession();
rex_login::startSession();
self::setSessionVar('UID', $me->getId());
self::$me = $me;
}

/**
* @return null|rex_ycom_user
* @return rex_ycom_user|null
*/
public static function getUser()
{
Expand Down Expand Up @@ -596,8 +596,8 @@ public static function cleanReferer(string $refererURL): string
}

/**
* @param string[] $returnTos
* @param string[] $allowedDomains
* @param array<string> $returnTos
* @param array<string> $allowedDomains
*/
public static function getReturnTo(array $returnTos, array $allowedDomains): string
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/auth/lib/ycom_auth_rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function check(rex_ycom_user $user, string $rule_name = 'login_try_5_paus
}

/**
* @return string[]
* @return array<string>
*/
public function getOptions(): array
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/auth/lib/yform/trait_value_auth_extern.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ trait rex_yform_trait_value_auth_extern
{
/**
* @throws rex_exception
* @return array|string[]
* @return array|array<string>
*/
private function auth_loadSettings(): array
{
Expand Down
12 changes: 6 additions & 6 deletions plugins/auth/lib/yform/value/ycom_auth_cas.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

class rex_yform_value_ycom_auth_cas extends rex_yform_value_abstract
{
/** @var array|string[] */
/** @var array|array<string> */
private static array $requestAuthFunctions = ['auth', 'logout'];
private string $casFile = 'cas.php';

public function enterObject(): void
{
rex_login::startSession();

$casConfigPath = \rex_addon::get('ycom')->getDataPath($this->casFile);
$casConfigPath = rex_addon::get('ycom')->getDataPath($this->casFile);
if (!file_exists($casConfigPath)) {
throw new rex_exception('CAS Settings file not found [' . $casConfigPath . ']');
}
Expand Down Expand Up @@ -112,16 +112,16 @@ public function enterObject(): void
$params['ignorePassword'] = true;
$params['loginPassword'] = '';

$loginStatus = \rex_ycom_auth::login($params);
$loginStatus = rex_ycom_auth::login($params);
if (rex_ycom_auth::STATUS_HAS_LOGGED_IN == $loginStatus) {
// already logged in
rex_ycom_user::updateUser($data);
rex_response::sendCacheControl();
\rex_response::sendRedirect($returnTo);
rex_response::sendRedirect($returnTo);
}

// if user not found, check if exists, but no permission
$user = \rex_ycom_user::query()->where('email', $data['email'])->findOne();
$user = rex_ycom_user::query()->where('email', $data['email'])->findOne();
if ($user) {
$this->params['warning_messages'][] = ('' != $this->getElement(2)) ? $this->getElement(2) : '{{ saml.error.ycom_login_failed }}';
return;
Expand All @@ -142,7 +142,7 @@ public function enterObject(): void
$params['loginStay'] = false;
$params['filter'] = [];
$params['loginPassword'] = '';
$loginStatus = \rex_ycom_auth::login($params);
$loginStatus = rex_ycom_auth::login($params);

if (rex_ycom_auth::STATUS_HAS_LOGGED_IN != $loginStatus) {
if ($this->params['debug']) {
Expand Down
7 changes: 4 additions & 3 deletions plugins/auth/lib/yform/value/ycom_auth_oauth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@

use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Provider\GenericProvider;
use League\OAuth2\Client\Token\AccessToken;

class rex_yform_value_ycom_auth_oauth2 extends rex_yform_value_abstract
{
use rex_yform_trait_value_auth_extern;

/** @var array|string[] */
/** @var array|array<string> */
private array $auth_requestFunctions = ['init', 'code', 'state'];
private bool $auth_directLink = false;
/** @var array|string[] */
/** @var array|array<string> */
private array $auth_SessionVars = ['OAUTH2_oauth2state'];
private string $auth_ClassKey = 'oauth2';

Expand Down Expand Up @@ -74,7 +75,7 @@ public function enterObject(): void

$accessToken = null;
try {
/** @var \League\OAuth2\Client\Token\AccessToken $accessToken */
/** @var AccessToken $accessToken */
$accessToken = $provider->getAccessToken('authorization_code', [
'code' => $code,
]);
Expand Down
4 changes: 2 additions & 2 deletions plugins/auth/lib/yform/value/ycom_auth_saml.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class rex_yform_value_ycom_auth_saml extends rex_yform_value_abstract
{
use rex_yform_trait_value_auth_extern;

/** @var array|string[] */
/** @var array|array<string> */
private array $auth_requestFunctions = ['auth', 'sso', 'acs', 'slo', 'sls'];
private bool $auth_directLink = false;
/** @var array|string[] */
/** @var array|array<string> */
private array $auth_SessionVars = ['SAML_Userdata', 'SAML_NameId', 'SAML_SessionIndex', 'SAML_AuthNRequestID', 'SAML_LogoutRequestID', 'SAML_NameIdFormat', 'SAML_ssoDate'];
private string $auth_ClassKey = 'saml';

Expand Down
4 changes: 2 additions & 2 deletions plugins/group/lib/ycom_group.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class rex_ycom_group extends rex_yform_manager_dataset
{
/** @var string[] */
/** @var array<string> */
public static array $perms = [
'0' => 'translate:ycom_group_forallgroups',
'1' => 'translate:ycom_group_inallgroups',
Expand All @@ -14,7 +14,7 @@ class rex_ycom_group extends rex_yform_manager_dataset

/**
* @throws rex_exception
* @return string[]
* @return array<string>
*/
public static function getGroups(): array
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/media_auth/boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
return false;
}
$rex_media = $ep->getParam('element');
return \rex_ycom_media_auth::checkFrontendPerm($rex_media);
return rex_ycom_media_auth::checkFrontendPerm($rex_media);
});

rex_extension::register(['MEDIA_MANAGER_BEFORE_SEND'], static function (rex_extension_point $ep) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/media_auth/lib/ycom_media_auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class rex_ycom_media_auth extends rex_yform_manager_dataset
{
/** @var string[] */
/** @var array<string> */
public static array $perms = [
'0' => 'translate:ycom_perm_all',
'1' => 'translate:ycom_perm_only_logged_in',
Expand Down
4 changes: 2 additions & 2 deletions plugins/media_auth/lib/ycom_media_auth_rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class rex_ycom_media_auth_rules
{
/** @var array<string, array{'info': string, 'action': string[]}> */
/** @var array<string, array{'info': string, 'action': array<string>}> */
private array $rules;

public function __construct()
Expand Down Expand Up @@ -84,7 +84,7 @@ public function check($rule_name): void
}

/**
* @return string[]
* @return array<string>
*/
public function getOptions(): array
{
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/login_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public function testLogin()
];

$status = rex_ycom_auth::login($params);
static::assertEquals(rex_ycom_auth::STATUS_LOGIN_FAILED, $status);

self::assertEquals(rex_ycom_auth::STATUS_LOGIN_FAILED, $status);
}
}

0 comments on commit 7eb73e5

Please sign in to comment.