diff options
Diffstat (limited to 'app')
30 files changed, 39 insertions, 380 deletions
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a8c5158..a8c5158 100755..100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index f1078a9..043cad6 100755..100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -4,8 +4,6 @@ namespace App\Exceptions; use Exception; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; -use Illuminate\Support\Facades\View; -use \Symfony\Component\HttpKernel\Exception\HttpException; class Handler extends ExceptionHandler { @@ -48,21 +46,6 @@ class Handler extends ExceptionHandler */ public function render($request, Exception $exception) { - if ($exception instanceof HttpException) { - $statusCode = $exception->getStatusCode(); - switch ($statusCode) { - case '404': - $codeMessage = 'Page could not be found.'; - } - $errorMessage = $exception->getMessage() == '' ? (isset($codeMessage) ? $codeMessage : 'An unknown error occurred.') : $exception->getMessage(); - - - return response(View::make('errors.http', [ - 'ErrorMessage' => $errorMessage, - 'ErrorCode' => $statusCode - ]), $statusCode); - } - return parent::render($request, $exception); } } 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.')); - } -} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 3439540..fb9616a 100755..100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -14,7 +14,7 @@ class Kernel extends HttpKernel * @var array */ protected $middleware = [ - \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, + \App\Http\Middleware\CheckForMaintenanceMode::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, diff --git a/app/Http/Middleware/CheckForMaintenanceMode.php b/app/Http/Middleware/CheckForMaintenanceMode.php new file mode 100644 index 0000000..35b9824 --- /dev/null +++ b/app/Http/Middleware/CheckForMaintenanceMode.php @@ -0,0 +1,17 @@ +<?php + +namespace App\Http\Middleware; + +use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware; + +class CheckForMaintenanceMode extends Middleware +{ + /** + * The URIs that should be reachable while maintenance mode is enabled. + * + * @var array + */ + protected $except = [ + // + ]; +} diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php index 033136a..033136a 100755..100644 --- a/app/Http/Middleware/EncryptCookies.php +++ b/app/Http/Middleware/EncryptCookies.php diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index e27860e..e4cec9c 100755..100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -18,7 +18,7 @@ class RedirectIfAuthenticated public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { - return redirect('/'); + return redirect('/home'); } return $next($request); diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php index 5a50e7b..5a50e7b 100755..100644 --- a/app/Http/Middleware/TrimStrings.php +++ b/app/Http/Middleware/TrimStrings.php diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index 7daf51f..7daf51f 100755..100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 0c13b85..0c13b85 100755..100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php diff --git a/app/Jobs/SendVerificationEmail.php b/app/Jobs/SendVerificationEmail.php deleted file mode 100755 index 0a71f05..0000000 --- a/app/Jobs/SendVerificationEmail.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -namespace App\Jobs; - -use App\Mail\EmailVerification; -use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Queue\SerializesModels; -use Mail; - -class SendVerificationEmail implements ShouldQueue -{ - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - - protected $user; - - /** - * Create a new job instance. - * - * @return void - */ - public function __construct($user) - { - $this->user = $user; - } - - /** - * Execute the job. - * - * @return void - */ - public function handle() - { - $email = new EmailVerification($this->user); - Mail::to($this->user->email)->send($email); - } -} diff --git a/app/Mail/EmailVerification.php b/app/Mail/EmailVerification.php deleted file mode 100755 index 4f393ac..0000000 --- a/app/Mail/EmailVerification.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace App\Mail; - -use Illuminate\Bus\Queueable; -use Illuminate\Mail\Mailable; -use Illuminate\Queue\SerializesModels; - -class EmailVerification extends Mailable -{ - use Queueable, SerializesModels; - - protected $user; - - /** - * Create a new message instance. - * - * @return void - */ - public function __construct($user) - { - $this->user = $user; - } - - /** - * Build the message. - * - * @return $this - */ - public function build() - { - return $this->view('email.verify')->with([ - 'email_token' => $this->user->email_token, - ]); - } -} diff --git a/app/Message.php b/app/Message.php deleted file mode 100755 index 79a1afd..0000000 --- a/app/Message.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace App; - -use Illuminate\Database\Eloquent\Model; - -class Message extends Model -{ - /** - * The attributes that are mass assignable. - * - * @var array - */ - protected $fillable = [ - 'user_id', 'message', - ]; -} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 706c003..706c003 100755..100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 9784b1a..9784b1a 100755..100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 352cce4..352cce4 100755..100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index fca6152..fca6152 100755..100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index e91ab48..5ea48d3 100755..100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Route; +use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; class RouteServiceProvider extends ServiceProvider { @@ -52,12 +52,8 @@ class RouteServiceProvider extends ServiceProvider protected function mapWebRoutes() { Route::middleware('web') - ->namespace($this->namespace) - ->group(base_path('routes/web.php')); - - Route::middleware('web') - ->namespace($this->namespace) - ->group(base_path('routes/keys.php')); + ->namespace($this->namespace) + ->group(base_path('routes/web.php')); } /** @@ -70,8 +66,8 @@ class RouteServiceProvider extends ServiceProvider protected function mapApiRoutes() { Route::prefix('api') - ->middleware('api') - ->namespace($this->namespace) - ->group(base_path('routes/api.php')); + ->middleware('api') + ->namespace($this->namespace) + ->group(base_path('routes/api.php')); } } diff --git a/app/PublicKeys.php b/app/PublicKeys.php deleted file mode 100755 index 92f1b24..0000000 --- a/app/PublicKeys.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace App; - -use Illuminate\Database\Eloquent\Model; - -class PublicKeys extends Model -{ - /** - * The attributes that are mass assignable. - * - * @var array - */ - protected $fillable = [ - 'user_id', 'key' - ]; -} diff --git a/app/User.php b/app/User.php index 9dcf98e..bfd96a6 100755..100644 --- a/app/User.php +++ b/app/User.php @@ -1,19 +1,21 @@ <?php + namespace App; -use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; + /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ - 'name', 'email', 'password', 'prevHash', 'hash', 'email_token' + 'name', 'email', 'password', ]; /** @@ -22,6 +24,6 @@ class User extends Authenticatable * @var array */ protected $hidden = [ - 'password', 'remember_token', 'prevHash', + 'password', 'remember_token', ]; } |