mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Use replace getById user lookup with User model find built in function(does the same thing as custom function)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
2018-02-02 DariusIII
|
||||
* Chg: Use replace getById user lookup with User model find built in function(does the same thing as custom function)
|
||||
2018-02-01 DariusIII
|
||||
* Chg: Update sebastian/comparator to latest version
|
||||
* Chg: Use create method when adding users
|
||||
|
||||
+5
-5
@@ -529,12 +529,12 @@ class User extends Authenticatable
|
||||
*/
|
||||
public static function getByIdAndRssToken($userID, $rssToken)
|
||||
{
|
||||
$user = self::getById($userID);
|
||||
if ($user === false) {
|
||||
$user = self::query()->where('id', '=', $userID, true)->where('rsstoken', '=', $rssToken)->get();
|
||||
if ($user === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $user->rsstoken !== $rssToken ? false : $user;
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -788,7 +788,7 @@ class User extends Authenticatable
|
||||
return true;
|
||||
}
|
||||
if (isset($_COOKIE['uid'], $_COOKIE['idh'])) {
|
||||
$u = self::getById($_COOKIE['uid']);
|
||||
$u = self::find($_COOKIE['uid']);
|
||||
|
||||
if ((int) $u['user_roles_id'] !== self::ROLE_DISABLED && $_COOKIE['idh'] === self::hashSHA1($u['userseed'].$_COOKIE['uid'])) {
|
||||
self::login($_COOKIE['uid'], $_SERVER['REMOTE_ADDR']);
|
||||
@@ -845,7 +845,7 @@ class User extends Authenticatable
|
||||
*/
|
||||
public static function setCookies($userID): void
|
||||
{
|
||||
$user = self::getById($userID);
|
||||
$user = self::find($userID);
|
||||
$secure_cookie = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? '1' : '0');
|
||||
setcookie('uid', $userID, time() + 2592000, '/', null, $secure_cookie, true);
|
||||
setcookie('idh', self::hashSHA1($user['userseed'].$userID), time() + 2592000, '/', null, $secure_cookie, true);
|
||||
|
||||
@@ -86,7 +86,7 @@ final class NZBVortex
|
||||
$page = new Page;
|
||||
|
||||
$host = $page->serverurl;
|
||||
$data = User::getById(User::currentUserId());
|
||||
$data = User::find(User::currentUserId());
|
||||
$url = sprintf('%sgetnzb/%s.nzb&i=%s&r=%s', $host, $nzb, $data['id'], $data['rsstoken']);
|
||||
|
||||
$params = [
|
||||
@@ -248,7 +248,7 @@ final class NZBVortex
|
||||
*/
|
||||
protected function login()
|
||||
{
|
||||
$data = User::getById(User::currentUserId());
|
||||
$data = User::find(User::currentUserId());
|
||||
$cnonce = generateUuid();
|
||||
$hash = hash('sha256', sprintf('%s:%s:%s', $this->nonce, $cnonce, $data['nzbvortex_api_key']), true);
|
||||
$hash = base64_encode($hash);
|
||||
@@ -261,11 +261,11 @@ final class NZBVortex
|
||||
|
||||
$response = $this->sendRequest('auth/login', $params);
|
||||
|
||||
if ('successful' == $response['loginResult']) {
|
||||
if ('successful' === $response['loginResult']) {
|
||||
$this->session = $response['sessionID'];
|
||||
}
|
||||
|
||||
if ('failed' == $response['loginResult']) {
|
||||
if ('failed' === $response['loginResult']) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ final class NZBVortex
|
||||
*/
|
||||
protected function sendRequest($path, $params = [])
|
||||
{
|
||||
$data = User::getById(User::currentUserId());
|
||||
$data = User::find(User::currentUserId());
|
||||
|
||||
$url = sprintf('%s/api', $data['nzbvortex_server_url']);
|
||||
$params = http_build_query($params);
|
||||
|
||||
@@ -114,7 +114,7 @@ switch ($action) {
|
||||
if (isset($_GET['id'])) {
|
||||
$page->title = 'User Edit';
|
||||
$id = $_GET['id'];
|
||||
$user = User::getById($id);
|
||||
$user = User::find($id);
|
||||
|
||||
$page->smarty->assign('user', $user);
|
||||
}
|
||||
|
||||
@@ -334,9 +334,12 @@ class BasePage
|
||||
$this->smarty->display($this->page_template);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function setUserPreferences(): void
|
||||
{
|
||||
$this->userdata = User::getById(User::currentUserId());
|
||||
$this->userdata = User::find(User::currentUserId());
|
||||
$this->userdata['categoryexclusions'] = User::getCategoryExclusion(User::currentUserId());
|
||||
$this->userdata['rolecategoryexclusions'] = RoleExcludedCategory::getRoleCategoryExclusion($this->userdata['user_roles_id']);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ $gateway_id = env('MYCELIUM_GATEWAY_ID');
|
||||
$gateway_secret = env('MYCELIUM_GATEWAY_SECRET');
|
||||
|
||||
$userId = User::currentUserId();
|
||||
$user = User::getById($userId);
|
||||
$user = User::find($userId);
|
||||
$action = $_REQUEST['action'] ?? 'view';
|
||||
$donation = UserRole::query()->where('donation', '>', 0)->get(['id', 'name', 'donation', 'addyears']);
|
||||
$page->smarty->assign('donation', $donation);
|
||||
|
||||
@@ -28,7 +28,7 @@ if (isset($_GET['id'])) {
|
||||
$releases = new Releases(['Settings' => $page->settings]);
|
||||
$re = new ReleaseExtra;
|
||||
$data = Release::getByGuid($_GET['id']);
|
||||
$user = User::getById(User::currentUserId());
|
||||
$user = User::find(User::currentUserId());
|
||||
$cpapi = $user['cp_api'];
|
||||
$cpurl = $user['cp_url'];
|
||||
$releaseRegex = ReleaseRegex::query()->where('releases_id', '=', $data['id'])->first();
|
||||
|
||||
@@ -21,7 +21,7 @@ if (isset($_REQUEST['t']) && array_key_exists($_REQUEST['t'], $mtmp)) {
|
||||
$category = $_REQUEST['t'] + 0;
|
||||
}
|
||||
|
||||
$user = User::getById(User::currentUserId());
|
||||
$user = User::find(User::currentUserId());
|
||||
$cpapi = $user['cp_api'];
|
||||
$cpurl = $user['cp_url'];
|
||||
$page->smarty->assign('cpapi', $cpapi);
|
||||
|
||||
@@ -41,7 +41,7 @@ if ($privileged || ! $privateProfiles) {
|
||||
$downloadlist = UserDownload::getDownloadRequestsForUser($userID);
|
||||
$page->smarty->assign('downloadlist', $downloadlist);
|
||||
|
||||
$data = User::getById($userID);
|
||||
$data = User::find($userID);
|
||||
if (! $data) {
|
||||
$page->show404();
|
||||
}
|
||||
@@ -56,7 +56,7 @@ $page->smarty->assign(
|
||||
[
|
||||
'apirequests' => UserRequest::getApiRequests($userID),
|
||||
'grabstoday' => UserDownload::getDownloadRequests($userID),
|
||||
'userinvitedby' => $data['invitedby'] !== '' ? User::getById($data['invitedby']) : '',
|
||||
'userinvitedby' => $data['invitedby'] !== '' ? User::find($data['invitedby']) : '',
|
||||
'user' => $data,
|
||||
'privateprofiles' => $privateProfiles,
|
||||
'publicview' => $publicView,
|
||||
|
||||
@@ -18,7 +18,7 @@ if (! User::isLoggedIn()) {
|
||||
$action = $_REQUEST['action'] ?? 'view';
|
||||
|
||||
$userid = User::currentUserId();
|
||||
$data = User::getById($userid);
|
||||
$data = User::find($userid);
|
||||
if (! $data) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ if (! User::isLoggedIn()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$userData = User::getById(User::currentUserId());
|
||||
$userData = User::find(User::currentUserId());
|
||||
if (! $userData) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ if (empty($_GET['id'])) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
$user = User::getById(User::currentUserId());
|
||||
if ($user['queuetype'] != 2) {
|
||||
$user = User::find(User::currentUserId());
|
||||
if ((int) $user['queuetype'] !== 2) {
|
||||
$sab = new SABnzbd($page);
|
||||
if (empty($sab->url)) {
|
||||
$page->show404();
|
||||
@@ -22,7 +22,7 @@ if ($user['queuetype'] != 2) {
|
||||
$page->show404();
|
||||
}
|
||||
$sab->sendToSab($_GET['id']);
|
||||
} elseif ($user['queuetype'] == 2) {
|
||||
} elseif ((int) $user['queuetype'] === 2) {
|
||||
$nzbget = new NZBGet($page);
|
||||
$nzbget->sendURLToNZBGet($_GET['id']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user