Skip to content

Commit fda1a31

Browse files
committed
✨ Initial Commit
0 parents  commit fda1a31

File tree

3,979 files changed

+267284
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,979 files changed

+267284
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.yml]
15+
indent_size = 2

.env.example

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
LOG_CHANNEL=stack
7+
8+
DB_CONNECTION=mysql
9+
DB_HOST=127.0.0.1
10+
DB_PORT=3306
11+
DB_DATABASE=blog
12+
DB_USERNAME=root
13+
DB_PASSWORD=sg24@4494
14+
15+
BROADCAST_DRIVER=log
16+
CACHE_DRIVER=file
17+
QUEUE_CONNECTION=sync
18+
SESSION_DRIVER=file
19+
SESSION_LIFETIME=120
20+
21+
REDIS_HOST=127.0.0.1
22+
REDIS_PASSWORD=null
23+
REDIS_PORT=6379
24+
25+
MAIL_DRIVER=smtp
26+
MAIL_HOST=smtp.mailtrap.io
27+
MAIL_PORT=2525
28+
MAIL_USERNAME=null
29+
MAIL_PASSWORD=null
30+
MAIL_ENCRYPTION=null
31+
32+
AWS_ACCESS_KEY_ID=
33+
AWS_SECRET_ACCESS_KEY=
34+
AWS_DEFAULT_REGION=us-east-1
35+
AWS_BUCKET=
36+
37+
PUSHER_APP_ID=
38+
PUSHER_APP_KEY=
39+
PUSHER_APP_SECRET=
40+
PUSHER_APP_CLUSTER=mt1
41+
42+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
43+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/storage/*.key
5+
/vendor
6+
.env
7+
.env.backup
8+
.phpunit.result.cache
9+
Homestead.json
10+
Homestead.yaml
11+
npm-debug.log
12+
yarn-error.log
13+
.idea
14+
/public/uploads

.styleci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
php:
2+
preset: laravel
3+
disabled:
4+
- unused_use
5+
finder:
6+
not-name:
7+
- index.php
8+
- server.php
9+
js:
10+
finder:
11+
not-name:
12+
- webpack.mix.js
13+
css: true

AssignmentDocumentation.pdf

516 KB
Binary file not shown.

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: vendor/bin/heroku-php-apache2 public/

app/Console/Kernel.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* The Artisan commands provided by your application.
12+
*
13+
* @var array
14+
*/
15+
protected $commands = [
16+
//
17+
];
18+
19+
/**
20+
* Define the application's command schedule.
21+
*
22+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
23+
* @return void
24+
*/
25+
protected function schedule(Schedule $schedule)
26+
{
27+
// $schedule->command('inspire')
28+
// ->hourly();
29+
}
30+
31+
/**
32+
* Register the commands for the application.
33+
*
34+
* @return void
35+
*/
36+
protected function commands()
37+
{
38+
$this->load(__DIR__.'/Commands');
39+
40+
require base_path('routes/console.php');
41+
}
42+
}

app/Exceptions/Handler.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Exception;
6+
use Illuminate\Auth\AuthenticationException;
7+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
8+
9+
class Handler extends ExceptionHandler
10+
{
11+
/**
12+
* A list of the exception types that are not reported.
13+
*
14+
* @var array
15+
*/
16+
protected $dontReport = [
17+
//
18+
];
19+
20+
/**
21+
* A list of the inputs that are never flashed for validation exceptions.
22+
*
23+
* @var array
24+
*/
25+
protected $dontFlash = [
26+
'password',
27+
'password_confirmation',
28+
];
29+
30+
/**
31+
* Report or log an exception.
32+
*
33+
* @param \Exception $exception
34+
* @return void
35+
*/
36+
public function report(Exception $exception)
37+
{
38+
parent::report($exception);
39+
}
40+
41+
/**
42+
* Render an exception into an HTTP response.
43+
*
44+
* @param \Illuminate\Http\Request $request
45+
* @param \Exception $exception
46+
* @return \Illuminate\Http\Response
47+
*/
48+
public function render($request, Exception $exception)
49+
{
50+
return parent::render($request, $exception);
51+
}
52+
53+
protected function unauthenticated($request, AuthenticationException $exception)
54+
{
55+
if ($request->expectsJson()) {
56+
return response()->json(['state' => 0, 'message' => 'Unauthenticated.'], 401);
57+
}
58+
59+
return redirect()->guest(route('auth.login'));
60+
}
61+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
7+
8+
class ForgotPasswordController extends Controller
9+
{
10+
/*
11+
|--------------------------------------------------------------------------
12+
| Password Reset Controller
13+
|--------------------------------------------------------------------------
14+
|
15+
| This controller is responsible for handling password reset emails and
16+
| includes a trait which assists in sending these notifications from
17+
| your application to your users. Feel free to explore this trait.
18+
|
19+
*/
20+
21+
use SendsPasswordResetEmails;
22+
23+
/**
24+
* Create a new controller instance.
25+
*
26+
* @return void
27+
*/
28+
public function __construct()
29+
{
30+
$this->middleware('guest');
31+
}
32+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Foundation\Auth\AuthenticatesUsers;
7+
use Illuminate\Http\Request;
8+
use Illuminate\Support\Facades\Auth;
9+
use Illuminate\Support\Str;
10+
11+
class LoginController extends Controller
12+
{
13+
/*
14+
|--------------------------------------------------------------------------
15+
| Login Controller
16+
|--------------------------------------------------------------------------
17+
|
18+
| This controller handles authenticating users for the application and
19+
| redirecting them to your home screen. The controller uses a trait
20+
| to conveniently provide its functionality to your applications.
21+
|
22+
*/
23+
24+
use AuthenticatesUsers;
25+
26+
/**
27+
* Where to redirect users after login.
28+
*
29+
* @var string
30+
*/
31+
protected $redirectTo = '/home';
32+
33+
/**
34+
* Create a new controller instance.
35+
*
36+
* @return void
37+
*/
38+
public function __construct()
39+
{
40+
$this->middleware('guest')->except('logout', 'checkAuth');
41+
}
42+
43+
public function login(Request $request)
44+
{
45+
$this->validateLogin($request);
46+
47+
if ($this->attemptLogin($request)) {
48+
$user = $this->guard()->user();
49+
50+
51+
$api_token = Str::random(60);
52+
53+
$user->api_token = $api_token;
54+
55+
$user->save();
56+
57+
return response()->json([
58+
'user' => $user->toArray(),
59+
]);
60+
}
61+
62+
return $this->sendFailedLoginResponse($request);
63+
}
64+
65+
public function logout(Request $request)
66+
{
67+
$user = Auth::guard('api')->user();
68+
69+
if ($user) {
70+
$user->api_token = null;
71+
$user->save();
72+
73+
return response()->json(['data' => 'User logged out.'], 200);
74+
}
75+
76+
return response()->json(['state' => 0, 'message' => 'Unauthenticated'], 401);
77+
}
78+
79+
public function checkAuth(Request $request)
80+
{
81+
$user = Auth::guard('api')->user();
82+
83+
return response()->json(['state' => 1], 200);
84+
}
85+
}

0 commit comments

Comments
 (0)