mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-01-23 20:39:43 -06:00
60 lines
2.1 KiB
PHP
60 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* NOTICE OF LICENSE.
|
|
*
|
|
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
|
* The details is bundled with this project in the file LICENSE.txt.
|
|
*
|
|
* @project UNIT3D Community Edition
|
|
*
|
|
* @author Roardom <roardom@protonmail.com>
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
|
*/
|
|
|
|
namespace App\Http\Controllers\User;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\PrivateMessage;
|
|
use App\Models\User;
|
|
use Illuminate\Http\Request;
|
|
|
|
class RsskeyController extends Controller
|
|
{
|
|
/**
|
|
* Update user rsskey.
|
|
*/
|
|
protected function update(Request $request, User $user): \Illuminate\Http\RedirectResponse
|
|
{
|
|
abort_unless($request->user()->id == $user->id || $request->user()->group->is_modo, 403);
|
|
|
|
$changedByStaff = $request->user()->id !== $user->id;
|
|
|
|
abort_if($changedByStaff && ! $request->user()->group->is_owner && $request->user()->group->level < $user->group->level, 403);
|
|
|
|
$user->rsskey = md5(random_bytes(60).$user->password);
|
|
$user->save();
|
|
|
|
if ($changedByStaff) {
|
|
PrivateMessage::create([
|
|
'sender_id' => 1,
|
|
'receiver_id' => $user->id,
|
|
'subject' => 'ATTENTION - Your RSS key has been reset',
|
|
'message' => "Your RSS key has been reset by staff. You will need to update your RSS key in your torrent client to continue receiving new torrents.\n\nFor more information, please create a helpdesk ticket.\n\n[color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]",
|
|
]);
|
|
}
|
|
|
|
return to_route('users.rsskey.edit', ['user' => $user])
|
|
->withSuccess('Your RSS key was changed successfully.');
|
|
}
|
|
|
|
/**
|
|
* Edit user rsskey.
|
|
*/
|
|
public function edit(Request $request, User $user): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
{
|
|
abort_unless($request->user()->id == $user->id || $request->user()->group->is_modo, 403);
|
|
|
|
return view('user.rsskey.edit', ['user' => $user]);
|
|
}
|
|
}
|