Enable Patron login required for ebook feeds

This commit is contained in:
Alex Cabal 2022-07-25 12:26:29 -05:00
parent 85372aa275
commit 850ad44e83
2 changed files with 28 additions and 19 deletions

View file

@ -114,14 +114,15 @@ class User extends PropertiesBase{
return $result[0];
}
public static function GetIfRegistered(?string $email): User{
public static function GetIfRegistered(?string $identifier): User{
// We consider a user "registered" if they have a row in the Benefits table.
// Emails without that row may only be signed up for the newsletter and thus are not "registered" users
if($email === null){
// The identifier is either an email or a UUID (api key)
if($identifier === null){
throw new Exceptions\InvalidUserException();
}
$result = Db::Query('SELECT u.* from Users u inner join Benefits using (UserId) where u.Email = ?', [$email], 'User');
$result = Db::Query('SELECT u.* from Users u inner join Benefits using (UserId) where u.Email = ? or u.Uuid = ?', [$identifier, $identifier], 'User');
if(sizeof($result) == 0){
throw new Exceptions\InvalidUserException();