Skip to content

Commit

Permalink
until ep 24(creating admin roles)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibrahima-prog committed Jan 3, 2020
1 parent d5a9eb1 commit 536d7bb
Show file tree
Hide file tree
Showing 26 changed files with 1,175 additions and 67 deletions.
88 changes: 88 additions & 0 deletions Raw files/admin/build/scss/_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,91 @@
width: $sidebar-user-image-width;
}
}
.navbar-nav > .user-menu {
> .nav-link:after {
content:none;
}
> .dropdown-menu {
@include border-top-radius(0);
padding: 0;
border-top-width: 0;
width: 280px;

&,
> .user-body {
@include border-bottom-radius(4px);
}

// Header menu
> li.user-header {
height: 175px;
padding: 10px;
text-align: center;
// User image
> img {
z-index: 5;
height: 90px;
width: 90px;
border: 3px solid;
border-color: transparent;
border-color: rgba(255, 255, 255, 0.2);
}
> p {
z-index: 5;
color: #fff;
color: rgba(255, 255, 255, 0.8);
font-size: 17px;
//text-shadow: 2px 2px 3px #333333;
margin-top: 10px;
> small {
display: block;
font-size: 12px;
}
}
}

// Menu Body
> .user-body {
padding: 15px;
border-bottom: 1px solid #f4f4f4;
border-top: 1px solid #dddddd;
@include clearfix();
a {
color: #444 !important;
@include media-breakpoint-up(sm) {
background: #fff !important;
color: #444 !important;
}
}
}

// Menu Footer
> .user-footer {
background-color: #f9f9f9;
padding: 10px;
@include clearfix();
.btn-default {
color: #666666;
&:hover {
@include media-breakpoint-up(sm) {
background-color: #f9f9f9;
}
}
}
}
}
.user-image {
float: left;
width: 25px;
height: 25px;
border-radius: 50%;
margin-right: 10px;
margin-top: -2px;
@include media-breakpoint-up(sm) {
float: none;
margin-right: 0;
margin-top: -8px;
line-height: 10px;
}
}
}
22 changes: 22 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Exceptions;

use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
Expand Down Expand Up @@ -48,4 +49,25 @@ public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
protected function unauthenticated($request, AuthenticationException $exception)
{
if ( $request->expectsJson()) {
# code...
return response()->json(['message' => $exception->getMessage()], 401);
}
$guard=$exception->guards();
//dd($guard[0]);
switch ($guard[0]) {
case 'admin':
return redirect()->guest('admin-login');
break;

default:
# code...
return redirect()->guest('login');
break;
}


}
}
40 changes: 40 additions & 0 deletions app/Http/Controllers/Admin/Auth/ConfirmPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Http\Controllers\Admin\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');
}
}
22 changes: 22 additions & 0 deletions app/Http/Controllers/Admin/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Http\Controllers\Admin\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/

use SendsPasswordResetEmails;
}
68 changes: 68 additions & 0 deletions app/Http/Controllers/Admin/Auth/LoginController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace App\Http\Controllers\Admin\Auth;

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

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;

class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/

use AuthenticatesUsers;

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

/**
* Create a new controller instance.
*
* @return void
*/
public function showLoginForm()
{
return view('admin.login');
}

public function login(Request $request)
{
$this->validateLogin($request);


if ($this->attemptLogin($request)) {
return $this->sendLoginResponse($request);
}


return $this->sendFailedLoginResponse($request);
}


public function __construct()
{
$this->middleware('guest:admin')->except('logout');
}

protected function guard()
{
return Auth::guard('admin');
}
}
73 changes: 73 additions & 0 deletions app/Http/Controllers/Admin/Auth/RegisterController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace App\Http\Controllers\Admin\Auth;

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

class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/

use RegistersUsers;

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

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}

/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'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 \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}
30 changes: 30 additions & 0 deletions app/Http/Controllers/Admin/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Controllers\Admin\Auth;

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

class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| 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;

/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
}
Loading

0 comments on commit 536d7bb

Please sign in to comment.