Skip to content

Commit

Permalink
upgrade packages
Browse files Browse the repository at this point in the history
  • Loading branch information
moeen-basra committed Dec 2, 2020
1 parent 552eafd commit 9f80bc1
Show file tree
Hide file tree
Showing 29 changed files with 295 additions and 196 deletions.
40 changes: 40 additions & 0 deletions app/Http/Controllers/Auth/ConfirmPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ConfirmsPasswords;

class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/

use ConfirmsPasswords;

/**
* Where to redirect users when the intended url fails.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
}
10 changes: 0 additions & 10 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,4 @@ class ForgotPasswordController extends Controller
*/

use SendsPasswordResetEmails;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
5 changes: 3 additions & 2 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
Expand All @@ -25,7 +26,7 @@ class LoginController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = RouteServiceProvider::HOME;

/**
* Create a new controller instance.
Expand All @@ -34,6 +35,6 @@ class LoginController extends Controller
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
$this->middleware('guest')->except('logout');
}
}
42 changes: 10 additions & 32 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace App\Http\Controllers\Auth;

use App\Models\User;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use App\Providers\RouteServiceProvider;
use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;

class RegisterController extends Controller
{
Expand All @@ -29,7 +29,7 @@ class RegisterController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = RouteServiceProvider::HOME;

/**
* Create a new controller instance.
Expand All @@ -50,46 +50,24 @@ public function __construct()
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}

/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
* @return \App\Models\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'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())));

if ($request->expectsJson()) {
return response()->json(['Created'], 201);
}

$this->guard()->login($user);

return $this->registered($request, $user)
?: redirect($this->redirectPath());
}
}
13 changes: 2 additions & 11 deletions app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ResetsPasswords;

class ResetPasswordController extends Controller
Expand All @@ -25,15 +26,5 @@ class ResetPasswordController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
protected $redirectTo = RouteServiceProvider::HOME;
}
42 changes: 42 additions & 0 deletions app/Http/Controllers/Auth/VerificationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\VerifiesEmails;

class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/

use VerifiesEmails;

/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}
2 changes: 2 additions & 0 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

class RouteServiceProvider extends ServiceProvider
{
const HOME = '/';

/**
* This namespace is applied to your controller routes.
*
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.12",
"laravel/sanctum": "^2.8",
"laravel/tinker": "^2.5"
"laravel/tinker": "^2.5",
"laravel/ui": "^3.1"
},
"require-dev": {
"facade/ignition": "^2.5",
Expand Down
60 changes: 59 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePasswordResetsTable extends Migration
{
Expand Down
8 changes: 4 additions & 4 deletions resources/js/app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* First we will load all of this project's JavaScript dependencies which
* includes React and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
* includes React and other helpers. It's a great starting point while
* building robust, powerful web applications using React + Laravel.
*/

require('./bootstrap')
require('./bootstrap');

/**
* Next, we will create a fresh React application instance and attach it to
* Next, we will create a fresh React component instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
Expand Down
1 change: 1 addition & 0 deletions resources/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ window._ = require('lodash');
window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
window.axios.defaults.withCredentials = true;

9 changes: 8 additions & 1 deletion resources/js/modules/article/pages/add/components/Form.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'

const displayName = 'ArticleFrom'
Expand Down Expand Up @@ -46,7 +47,13 @@ const Form = ({ article, errors, onChange, onSubmit }) => {
<div className="form-group row">
<label htmlFor="content" className="col-sm-2 col-form-label">Content</label>
<div className="col-sm-10">
<textarea id="content" value={article.content} onChange={e => handleChange('content', e)} />
<textarea id="content"
name="content"
className={`form-control ${errors.has('content') && 'is-invalid'}`}
rows="3"
placeholder="Content"
value={article.content}
onChange={e => handleChange(e.target.name, e.target.value)} />
{errors.has('content') && <div className="invalid-feedback">{errors.first('content')}</div>}
</div>
</div>
Expand Down
9 changes: 8 additions & 1 deletion resources/js/modules/article/pages/edit/components/Form.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'

const displayName = 'ArticleFrom'
Expand Down Expand Up @@ -46,7 +47,13 @@ const Form = ({ article, errors, onChange, onSubmit }) => {
<div className="form-group row">
<label htmlFor="content" className="col-sm-2 col-form-label">Content</label>
<div className="col-sm-10">
<textarea id="content" value={article.content} onChange={e => handleChange('content', e)} />
<textarea id="content"
name="content"
className={`form-control ${errors.has('content') && 'is-invalid'}`}
rows="3"
placeholder="Content"
value={article.content}
onChange={e => handleChange(e.target.name, e.target.value)} />
{errors.has('content') && <div className="invalid-feedback">{errors.first('content')}</div>}
</div>
</div>
Expand Down
Loading

0 comments on commit 9f80bc1

Please sign in to comment.