login
parent
5d8129ba9d
commit
dc58971bd4
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
|
||||
class CustomLoginController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
public function post_login(Request $request)
|
||||
{
|
||||
Validator::make($request->all(), [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
])->validate();
|
||||
|
||||
$credentials = array('email' => $request->email, 'password' => $request->password);
|
||||
|
||||
$user = User::where('email', $credentials['email'])->first();
|
||||
|
||||
if ($user && Hash::check($credentials['password'], $user->password)) {
|
||||
Auth::attempt(['email' => $request->email, 'password' => $request->password]);
|
||||
|
||||
return redirect('dashboard')->with([
|
||||
'message' => trans('Selamat datang kembali'),
|
||||
'type' => "success"
|
||||
]);
|
||||
|
||||
}else{
|
||||
return redirect('/login')
|
||||
->withInput()
|
||||
->with([
|
||||
'message' => trans('Akun anda tidak ditemukan'),
|
||||
'type' => "error"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
Auth::logout();
|
||||
return redirect('/login')
|
||||
->withInput()
|
||||
->with([
|
||||
'message' => trans('Berhasil Keluar'),
|
||||
'type' => "success"
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CustomRegisterController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('auth.register');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Auth;
|
||||
|
||||
class Session
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if(!Auth::check()){
|
||||
return redirect('/login')->with([
|
||||
'message' => 'Maaf anda harus login terlebih dahulu',
|
||||
'type' => "error"
|
||||
]);
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -17,6 +17,8 @@ class User extends Authenticatable
|
|||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $table = 'user';
|
||||
protected $primaryKey = 'user_id';
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
|
|
|
@ -69,7 +69,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
'timezone' => 'Asia/Jakarta',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -11,8 +11,8 @@ return new class extends Migration
|
|||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
Schema::create('user', function (Blueprint $table) {
|
||||
$table->id('user_id');
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Database\Seeders;
|
|||
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Hash;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
|
@ -12,6 +13,11 @@ class DatabaseSeeder extends Seeder
|
|||
*/
|
||||
public function run(): void
|
||||
{
|
||||
\DB::table('user')->insert([
|
||||
'name' => 'Administrator',
|
||||
'email' => 'adminadiwiyata@dlh.go.id',
|
||||
'password' => Hash::make('##SekolahAdiwiyata123'),
|
||||
]);
|
||||
// \App\Models\User::factory(10)->create();
|
||||
|
||||
// \App\Models\User::factory()->create([
|
||||
|
|
|
@ -42,30 +42,31 @@
|
|||
</div>
|
||||
<div class="col-sm-12 col-md-6 col-lg-5 col-xl-4 ml-auto">
|
||||
<div class="card p-4 rounded-plus bg-faded">
|
||||
<form id="js-login" novalidate="" action="{{url('dashboard')}}">
|
||||
@include('include.alert')
|
||||
<form id="js-login" validate="" method="POST" action="{{url('login')}}">
|
||||
{{csrf_field()}}
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="username">Email</label>
|
||||
<input type="email" id="email" class="form-control form-control-lg" placeholder="Masukan Email anda" value="" required>
|
||||
<label class="form-label">Email</label>
|
||||
<input type="email" id="email" required name="email" class="form-control" placeholder="Masukan Email anda" value="" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="password">Password</label>
|
||||
<input type="password" id="password" class="form-control form-control-lg" placeholder="Masukan Password" required>
|
||||
</div>
|
||||
<div class="form-group text-left">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input">
|
||||
<label class="custom-control-label"> Lihat Password</label>
|
||||
<label class="form-label">Password</label>
|
||||
<div class="input-group">
|
||||
<input type="password" required id="password" name="password" class="form-control" placeholder="Masukan Password">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-default waves-effect waves-themed" type="button" id="button-addon5"><i class="fal fa-eye"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row no-gutters">
|
||||
<div class="col-lg-12 pr-lg-1 my-2">
|
||||
<button type="submit" class="btn btn-info btn-block btn-lg">Masuk</button>
|
||||
<button type="submit" class="btn btn-info btn-block">Masuk</button>
|
||||
</div>
|
||||
<div class="col-lg-12 pl-lg-1 my-2 text-center">
|
||||
OR
|
||||
</div>
|
||||
<div class="col-lg-12 pl-lg-1 my-2">
|
||||
<a href="{{url('register')}}" class="btn btn-danger btn-block btn-lg">Registrasi Sekolah</a>
|
||||
<a href="{{url('register')}}" class="btn btn-danger btn-block">Registrasi Sekolah</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
<div class="alert alert-primary text-center text-dark" role="alert">
|
||||
<h4>Registrasi Sekolah</h4>
|
||||
</div>
|
||||
@include('include.alert')
|
||||
<form id="js-login" novalidate="" action="intel_analytics_dashboard.html">
|
||||
<div class="form-group row">
|
||||
<label class="col-xl-12 form-label" for="fname">NPSN</label>
|
||||
|
@ -100,8 +101,13 @@
|
|||
<small class="text-primary">* Pastikan email benar dan aktif, akses aplikasi akan dikirim ke email yang didaftarkan.</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="userpassword">Password</label>
|
||||
<input type="password" id="userpassword" class="form-control" placeholder="Masukan Password Minimm 8 characters" required>
|
||||
<label class="form-label">Password</label>
|
||||
<div class="input-group">
|
||||
<input type="password" id="password" name="password" class="form-control" placeholder="Masukan Password Minimm 8 characters" required>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-default waves-effect waves-themed" type="button" id="button-addon5"><i class="fal fa-eye"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="help-block">Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
@if(session()->get('type')=='error')
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<div class="alert-body"><i class="fal fa-exclamation-triangle"></i> {{ session('message') }} </div>
|
||||
</div>
|
||||
@elseif (session()->get('type')=='success')
|
||||
<div class="alert alert-success" role="alert">
|
||||
<div class="alert-body"><i class="fal fa-check-circle fa-1x"></i> {{ session('message') }}.</div>
|
||||
</div>
|
||||
@elseif (session()->get('type')=='warning')
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<div class="alert-body"><i class="fal fa-exclamation-triangle"></i> {{ session('message') }}.</div>
|
||||
</div>
|
||||
@endif
|
|
@ -42,7 +42,7 @@
|
|||
<span data-i18n="drpdwn.settings">Settings</span>
|
||||
</a>
|
||||
<div class="dropdown-divider m-0"></div>
|
||||
<a class="dropdown-item fw-500 pt-3 pb-3" href="{{url('login')}}">
|
||||
<a class="dropdown-item fw-500 pt-3 pb-3" href="{{url('logout')}}">
|
||||
<span data-i18n="drpdwn.page-logout">Logout</span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
<!-- BEGIN Page Content -->
|
||||
<!-- the #js-page-content id is needed for some plugins to initialize -->
|
||||
<main id="js-page-content" role="main" class="page-content">
|
||||
@include('include.alert')
|
||||
<ol class="breadcrumb page-breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">SmartAdmin</a></li>
|
||||
<li class="breadcrumb-item">Application Intel</li>
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Middleware\Session;
|
||||
use App\Http\Controllers\Auth\CustomLoginController;
|
||||
use App\Http\Controllers\Auth\CustomRegisterController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -12,19 +15,29 @@ use Illuminate\Support\Facades\Route;
|
|||
| be assigned to the "web" middleware group. Make something great!
|
||||
|
|
||||
*/
|
||||
Route::get('login',[CustomLoginController::class,'index'])->name('login');
|
||||
Route::post('login',[CustomLoginController::class,'post_login'])->name('post_login');
|
||||
|
||||
Route::get('register',[CustomRegisterController::class,'index'])->name('register');
|
||||
Route::post('register',[CustomRegisterController::class,'post_register'])->name('post_register');
|
||||
|
||||
Route::middleware(Session::class)->name('modules.')->group(function () {
|
||||
Route::get('/dashboard', function () {
|
||||
return view('home');
|
||||
});
|
||||
|
||||
Route::get('/profile-sekolah', function () {
|
||||
return view('profile');
|
||||
});
|
||||
|
||||
Route::get('logout',[CustomLoginController::class,'logout'])->name('logout');
|
||||
});
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
return redirect('login');
|
||||
});
|
||||
|
||||
Route::get('/dashboard', function () {
|
||||
return view('home');
|
||||
});
|
||||
|
||||
Route::get('/profile-sekolah', function () {
|
||||
return view('profile');
|
||||
});
|
||||
|
||||
Auth::routes();
|
||||
|
||||
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
|
||||
// Auth::routes();
|
||||
// Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
|
||||
|
|
Loading…
Reference in New Issue