Skip to content

Commit

Permalink
Use $this->userdata->id variable in place of Auth::(id) in controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Sep 24, 2018
1 parent b7fef38 commit 23ab8f0
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 43 deletions.
2 changes: 2 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2018-09-24 DariusIII
* Chg: Use $this->userdata->id variable in place of Auth::(id) in controllers
2018-09-22 DariusIIi
* Fix: Fix user login by email
2018-09-21 DariusIII
Expand Down
11 changes: 6 additions & 5 deletions app/Http/Controllers/BasePageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ class BasePageController extends Controller
public $page_template = '';

/**
* User settings from the MySQL DB.
*
* @var array|bool
* @var User
*/
public $userdata = [];
public $userdata;

/**
* User's theme.
Expand Down Expand Up @@ -243,7 +241,7 @@ protected function setUserPreferences(): void

// Update last login every 15 mins.
if ((strtotime($this->userdata['now']) - 900) > strtotime($this->userdata['lastlogin'])) {
User::updateSiteAccessed($this->userdata['id']);
User::updateSiteAccessed($this->userdata->id);
}

$this->smarty->assign('userdata', $this->userdata);
Expand Down Expand Up @@ -302,6 +300,9 @@ protected function setUserPreferences(): void
$this->smarty->assign('header_menu', $header_menu);
}

/**
* Set admin preferences
*/
public function setAdminPrefs()
{
// Tell Smarty which directories to use for templates
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function store(Request $request)
}

foreach ($data as $d) {
UsersRelease::addCart(Auth::id(), $d['id']);
UsersRelease::addCart($this->userdata->id, $d['id']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/DetailsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function show($guid)
}

if ($this->isPostBack()) {
ReleaseComment::addComment($data['id'], $data['gid'], \request()->input('txtAddComment'), Auth::id(), \request()->ip());
ReleaseComment::addComment($data['id'], $data['gid'], \request()->input('txtAddComment'), $this->userdata->id, \request()->ip());
}

$nfo = ReleaseNfo::getReleaseNfo($data['id']);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/FailedReleasesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function show(Request $request)
$this->setPrefs();
// Page is accessible only by the rss token, or logged in users.
if (Auth::check()) {
$uid = Auth::id();
$uid = $this->userdata->id;
$rssToken = $this->userdata['api_token'];
} else {
if (! $request->has('userid') || ! $request->has('api_token')) {
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ForumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function forum(Request $request)
{
$this->setPrefs();
if ($this->isPostBack() && $request->has('addMessage') && $request->has('addSubject')) {
Forumpost::add(0, Auth::id(), $request->input('addSubject'), $request->input('addMessage'));
Forumpost::add(0, $this->userdata->id, $request->input('addSubject'), $request->input('addMessage'));

return redirect('forum');
}
Expand Down Expand Up @@ -79,7 +79,7 @@ public function getPosts($id, Request $request)
$this->setPrefs();

if ($request->has('addMessage') && $this->isPostBack()) {
Forumpost::add($id, Auth::id(), '', $request->input('addMessage'));
Forumpost::add($id, $this->userdata->id, '', $request->input('addMessage'));

return redirect('forumpost/'.$id.'#last');
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/GetNzbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function getNzb(Request $request)

// Page is accessible only by the rss token, or logged in users.
if (Auth::check()) {
$uid = Auth::id();
$uid = $this->userdata->id;
$maxDownloads = $this->userdata->role->downloadrequests;
$rssToken = $this->userdata['api_token'];
if ($this->userdata->hasRole('Disabled') === true) {
Expand Down
12 changes: 6 additions & 6 deletions app/Http/Controllers/MyMoviesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function show(Request $request)

switch ($action) {
case 'delete':
$movie = UserMovie::getMovie(Auth::id(), $imdbid);
$movie = UserMovie::getMovie($this->userdata->id, $imdbid);
if ($request->has('from')) {
header('Location:'.WWW_TOP.$request->input('from'));
} else {
Expand All @@ -42,13 +42,13 @@ public function show(Request $request)
if (! $movie) {
$this->show404();
} else {
UserMovie::delMovie(Auth::id(), $imdbid);
UserMovie::delMovie($this->userdata->id, $imdbid);
}

break;
case 'add':
case 'doadd':
$movie = UserMovie::getMovie(Auth::id(), $imdbid);
$movie = UserMovie::getMovie($this->userdata->id, $imdbid);
if ($movie) {
$this->show404();
} else {
Expand All @@ -60,7 +60,7 @@ public function show(Request $request)

if ($action === 'doadd') {
$category = ($request->has('category') && \is_array($request->input('category')) && ! empty($request->input('category'))) ? $request->input('category') : [];
UserMovie::addMovie(Auth::id(), $imdbid, $category);
UserMovie::addMovie($this->userdata->id, $imdbid, $category);
if ($request->has('from')) {
header('Location:'.WWW_TOP.$request->input('from'));
} else {
Expand Down Expand Up @@ -89,15 +89,15 @@ public function show(Request $request)
break;
case 'edit':
case 'doedit':
$movie = UserMovie::getMovie(Auth::id(), $imdbid);
$movie = UserMovie::getMovie($this->userdata->id, $imdbid);

if (! $movie) {
$this->show404();
}

if ($action === 'doedit') {
$category = ($request->has('category') && \is_array($request->input('category')) && ! empty($request->input('category'))) ? $request->input('category') : [];
UserMovie::updateMovie(Auth::id(), $imdbid, $category);
UserMovie::updateMovie($this->userdata->id, $imdbid, $category);
if ($request->has('from')) {
redirect($request->input('from'));
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function edit(Request $request)

$action = $request->input('action') ?? 'view';

$userid = Auth::id();
$userid = $this->userdata->id;
$data = User::find($userid);
if (! $data) {
$this->show404('No such user!');
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/RssController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function rss(Request $request)
$uid = -1;
// User requested a feed, ensure either logged in or passing a valid token.
if (Auth::check()) {
$uid = Auth::id();
$uid = $this->userdata->id;
$rssToken = $this->userdata['api_token'];
$maxRequests = $this->userdata->role->apirequests;
} else {
Expand Down
Loading

0 comments on commit 23ab8f0

Please sign in to comment.