Cleaned up some unessasary facade usage
This commit is contained in:
parent
eac7378ce0
commit
6b6f6d2c92
|
@ -30,16 +30,16 @@ abstract class Controller extends BaseController
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Get a user instance for the current user
|
// Get a user instance for the current user
|
||||||
$user = Auth::user();
|
$user = auth()->user();
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$user = User::getDefault();
|
$user = User::getDefault();
|
||||||
}
|
}
|
||||||
// Share variables with views
|
// Share variables with views
|
||||||
view()->share('signedIn', Auth::check());
|
view()->share('signedIn', auth()->check());
|
||||||
view()->share('currentUser', $user);
|
view()->share('currentUser', $user);
|
||||||
// Share variables with controllers
|
// Share variables with controllers
|
||||||
$this->currentUser = $user;
|
$this->currentUser = $user;
|
||||||
$this->signedIn = Auth::check();
|
$this->signedIn = auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -64,7 +64,7 @@ class UserController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user = $this->user->fill($request->all());
|
$user = $this->user->fill($request->all());
|
||||||
$user->password = Hash::make($request->get('password'));
|
$user->password = bcrypt($request->get('password'));
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$user->attachRoleId($request->get('role'));
|
$user->attachRoleId($request->get('role'));
|
||||||
|
@ -120,7 +120,7 @@ class UserController extends Controller
|
||||||
if ($request->has('password') && $request->get('password') != '') {
|
if ($request->has('password') && $request->get('password') != '') {
|
||||||
//dd('cat');
|
//dd('cat');
|
||||||
$password = $request->get('password');
|
$password = $request->get('password');
|
||||||
$user->password = Hash::make($password);
|
$user->password = bcrypt($password);
|
||||||
}
|
}
|
||||||
$user->save();
|
$user->save();
|
||||||
return redirect('/users');
|
return redirect('/users');
|
||||||
|
|
|
@ -43,6 +43,7 @@ Route::group(['middleware' => 'auth'], function () {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Uploads
|
||||||
Route::post('/upload/image', 'ImageController@upload');
|
Route::post('/upload/image', 'ImageController@upload');
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
|
@ -75,7 +76,6 @@ Route::group(['middleware' => 'auth'], function () {
|
||||||
Route::get('/settings', 'SettingController@index');
|
Route::get('/settings', 'SettingController@index');
|
||||||
Route::post('/settings', 'SettingController@update');
|
Route::post('/settings', 'SettingController@update');
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Login using social authentication
|
// Login using social authentication
|
||||||
|
|
|
@ -60,8 +60,8 @@ class SocialAuthService
|
||||||
// Get any attached social accounts or users
|
// Get any attached social accounts or users
|
||||||
$socialAccount = $this->socialAccount->where('driver_id', '=', $socialId)->first();
|
$socialAccount = $this->socialAccount->where('driver_id', '=', $socialId)->first();
|
||||||
$user = $this->userRepo->getByEmail($socialUser->getEmail());
|
$user = $this->userRepo->getByEmail($socialUser->getEmail());
|
||||||
$isLoggedIn = \Auth::check();
|
$isLoggedIn = auth()->check();
|
||||||
$currentUser = \Auth::user();
|
$currentUser = auth()->user();
|
||||||
|
|
||||||
// When a user is not logged in but a matching SocialAccount exists,
|
// When a user is not logged in but a matching SocialAccount exists,
|
||||||
// Log the user found on the SocialAccount into the application.
|
// Log the user found on the SocialAccount into the application.
|
||||||
|
@ -115,7 +115,7 @@ class SocialAuthService
|
||||||
|
|
||||||
private function logUserIn($user)
|
private function logUserIn($user)
|
||||||
{
|
{
|
||||||
\Auth::login($user);
|
auth()->login($user);
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,9 +183,10 @@ class SocialAuthService
|
||||||
*/
|
*/
|
||||||
public function detachSocialAccount($socialDriver)
|
public function detachSocialAccount($socialDriver)
|
||||||
{
|
{
|
||||||
\Auth::user()->socialAccounts()->where('driver', '=', $socialDriver)->delete();
|
session();
|
||||||
|
auth()->user()->socialAccounts()->where('driver', '=', $socialDriver)->delete();
|
||||||
\Session::flash('success', $socialDriver . ' account successfully detached');
|
\Session::flash('success', $socialDriver . ' account successfully detached');
|
||||||
return redirect(\Auth::user()->getEditUrl());
|
return redirect(auth()->user()->getEditUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue