aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Http/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/Http/Controllers')
-rwxr-xr-xapp/Http/Controllers/AdminController.php28
-rw-r--r--app/Http/Controllers/ApiController.php13
-rw-r--r--[-rwxr-xr-x]app/Http/Controllers/Auth/ForgotPasswordController.php0
-rw-r--r--[-rwxr-xr-x]app/Http/Controllers/Auth/LoginController.php10
-rw-r--r--[-rwxr-xr-x]app/Http/Controllers/Auth/RegisterController.php51
-rw-r--r--[-rwxr-xr-x]app/Http/Controllers/Auth/ResetPasswordController.php4
-rw-r--r--[-rwxr-xr-x]app/Http/Controllers/Controller.php0
-rwxr-xr-xapp/Http/Controllers/ImageController.php17
-rwxr-xr-xapp/Http/Controllers/PublicKeyController.php49
-rwxr-xr-xapp/Http/Controllers/SocketController.php44
-rwxr-xr-xapp/Http/Controllers/UserController.php32
11 files changed, 9 insertions, 239 deletions
diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php
deleted file mode 100755
index b3c8443..0000000
--- a/app/Http/Controllers/AdminController.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use Auth;
-use Illuminate\Foundation\Auth\User;
-
-class AdminController extends Controller
-{
- public function Dashboard()
- {
- $this->checkAdmin();
- return view('admin.dashboard', [
- 'user' => Auth::user(),
- 'cpu_load' => round(sys_getloadavg()[1]/(trim(shell_exec("grep -P '^processor' /proc/cpuinfo|wc -l")) + 1)*100, 0)
- ]);
- }
-
- private function checkAdmin()
- {
- $isAdmin = User::findOrFail(Auth::user()->id)->admin;
- if ($isAdmin !== 1) {
- abort(403, 'Sorry, you are not an administrator.');
- }
-
- return true;
- }
-}
diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php
deleted file mode 100644
index ecd8079..0000000
--- a/app/Http/Controllers/ApiController.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use Illuminate\Http\Request;
-
-class ApiController extends Controller
-{
- public function getUserData(Request $request)
- {
- return $request->user();
- }
-}
diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php
index 6a247fe..6a247fe 100755..100644
--- a/app/Http/Controllers/Auth/ForgotPasswordController.php
+++ b/app/Http/Controllers/Auth/ForgotPasswordController.php
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index 87f66d5..b2ea669 100755..100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
-use Illuminate\Http\Request;
class LoginController extends Controller
{
@@ -17,21 +16,16 @@ class LoginController extends Controller
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
- */
+ */
use AuthenticatesUsers;
- protected function authenticated(Request $request, $user)
- {
- return redirect('/keys/cookie/public');
- }
-
/**
* Where to redirect users after login.
*
* @var string
*/
- protected $redirectTo = '/keys/cookie/public';
+ protected $redirectTo = '/home';
/**
* Create a new controller instance.
diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php
index 2994499..e749c07 100755..100644
--- a/app/Http/Controllers/Auth/RegisterController.php
+++ b/app/Http/Controllers/Auth/RegisterController.php
@@ -2,14 +2,11 @@
namespace App\Http\Controllers\Auth;
-use App\Http\Controllers\Controller;
-use App\Jobs\SendVerificationEmail;
use App\User;
-use Illuminate\Auth\Events\Registered;
-use Illuminate\Foundation\Auth\RegistersUsers;
-use Illuminate\Http\Request;
+use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
+use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
@@ -22,7 +19,7 @@ class RegisterController extends Controller
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
- */
+ */
use RegistersUsers;
@@ -31,7 +28,7 @@ class RegisterController extends Controller
*
* @var string
*/
- protected $redirectTo = '/keys/cookie/public';
+ protected $redirectTo = '/home';
/**
* Create a new controller instance.
@@ -66,48 +63,10 @@ class RegisterController extends Controller
*/
protected function create(array $data)
{
- $hashedPassword = Hash::make($data['password']);
- $previousHash = User::select('hash')->orderBy('id', 'desc')->first()->hash;
- $summedHash = Hash::make($previousHash . $data['name'] . $data['email'] . 'password' . $hashedPassword); // Hash::check to verify
-
return User::create([
'name' => $data['name'],
'email' => $data['email'],
- 'password' => $hashedPassword,
- 'prevHash' => $previousHash,
- 'hash' => $summedHash,
- 'email_token' => base64_encode($data['email']),
+ 'password' => Hash::make($data['password']),
]);
}
-
- /**
- * Handle a registration request for the application.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
-
- public function register(Request $request)
- {
- $this->validator($request->all())->validate();
- event(new Registered($user = $this->create($request->all())));
- dispatch(new SendVerificationEmail($user));
- return view('confirmEmail');
- }
-
- /**
- * Handle a registration request for the application.
- *
- * @param $token
- * @return \Illuminate\Http\Response
- */
- public function verifyEmail($token)
- {
- $user = User::where('email_token', $token)->first();
- $user->verified = 1;
- if ($user->save()) {
- return view('verificationSuccess', ['user' => $user]);
- }
- }
-
}
diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php
index f5edc22..cf726ee 100755..100644
--- a/app/Http/Controllers/Auth/ResetPasswordController.php
+++ b/app/Http/Controllers/Auth/ResetPasswordController.php
@@ -16,7 +16,7 @@ class ResetPasswordController extends Controller
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
- */
+ */
use ResetsPasswords;
@@ -25,7 +25,7 @@ class ResetPasswordController extends Controller
*
* @var string
*/
- protected $redirectTo = '/';
+ protected $redirectTo = '/home';
/**
* Create a new controller instance.
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 03e02a2..03e02a2 100755..100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
diff --git a/app/Http/Controllers/ImageController.php b/app/Http/Controllers/ImageController.php
deleted file mode 100755
index 603008d..0000000
--- a/app/Http/Controllers/ImageController.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use Illuminate\Http\Request;
-use Illuminate\Foundation\Auth\User;
-use Intervention\Image\ImageManagerStatic as Image;
-
-class ImageController extends Controller
-{
- public function getAvatar($user_id)
- {
- $usersAvatar = User::findOrFail($user_id)->avatar;
- $storagePath = storage_path('app/public/avatars/' . $usersAvatar);
- return Image::make($storagePath)->response();
- }
-}
diff --git a/app/Http/Controllers/PublicKeyController.php b/app/Http/Controllers/PublicKeyController.php
deleted file mode 100755
index af59cc2..0000000
--- a/app/Http/Controllers/PublicKeyController.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use App\PublicKeys;
-use Auth;
-use Cookie;
-use Illuminate\Foundation\Auth\User;
-use Illuminate\Http\Request;
-
-class PublicKeyController extends Controller
-{
- public function getUsersKey($user_id)
- {
- $public_key = PublicKeys::select('key')->where('user_id', $user_id)->first();
- // TODO: Friends: do not allow to request every public key
-
- return $public_key ? $public_key : abort(404, "This public key doesn't exist.");
- }
-
- public function setUsersKey(Request $request)
- {
- $request->validate([
- 'key' => 'required|max:4096',
- ]);
-
- $public_key = PublicKeys::firstOrNew(['user_id' => $user_id]);
- $public_key->user_id = $user_id;
- $public_key->key = $request->input('key');
- $public_key->save();
-
- return response()->json(['message' => 'Successfully inserted public key.'], 201);
- }
-
- public function setUsersKeyByCookie(Request $request)
- {
- if ($_COOKIE['publickey'] !== null) {
- $user = Auth::user();
- $public_key = PublicKeys::firstOrNew(['user_id' => $user->id]);
- $public_key->user_id = $user->id;
- $public_key->key = $_COOKIE['publickey'];
- $public_key->save();
-
- return redirect('/');
- } else {
- abort(400, "Public key is malformed.");
- }
- }
-}
diff --git a/app/Http/Controllers/SocketController.php b/app/Http/Controllers/SocketController.php
deleted file mode 100755
index dc95ad8..0000000
--- a/app/Http/Controllers/SocketController.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use App\Http\Controllers\Controller;
-use App\Message;
-use Auth;
-use Illuminate\Http\Request;
-use LRedis;
-
-class SocketController extends Controller
-{
- //Write Message
- public function writeMessage()
- {
- $messages = Message::leftJoin('users', function ($join) {
- $join->on('messages.user_id', '=', 'users.id');
- })
- ->select('users.name', 'messages.message')->orderBy('messages.created_at')
- ->get();
-
- return view('writeMessage', compact('messages'));
- }
-
- //Send Message
- public function sendMessage(Request $request)
- {
- $user = Auth::user();
-
- $input = $request->all();
- $redis = LRedis::connection();
-
- if (!isset($input['message']) || trim($input['message']) === '') {
- } else {
- Message::create([
- 'user_id' => $user->id,
- 'message' => $input['message'],
- ]);
-
- $data = ['message' => $input['message'], 'user' => $user->name];
- $redis->publish('message', json_encode($data));
- }
- }
-}
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
deleted file mode 100755
index 8d98a9a..0000000
--- a/app/Http/Controllers/UserController.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use Auth;
-use Illuminate\Foundation\Auth\User;
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Storage;
-use Intervention\Image\ImageManagerStatic as Image;
-
-class UserController extends Controller
-{
- public function Profile()
- {
- $user = Auth::user();
- return view('profile', compact('user', $user));
- }
-
- public function updateAvatar(Request $request)
- {
- $request->validate([
- 'avatar' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
- ]);
- $user = Auth::user();
- $avatarName = $user->id . '.' . $request->avatar->getClientOriginalExtension();
- $fittedAvatar = Image::make($request->avatar)->fit(256)->encode();
- Storage::put('avatars/' . $avatarName, (string) $fittedAvatar);
- $user->avatar = $avatarName;
- $user->save();
- return response()->json(array('success' => 'You have successfully uploaded the avatar.'));
- }
-}