masi login admin
This commit is contained in:
parent
e6cf4e6789
commit
62908813c7
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Tentukan ke mana redirect jika user belum login.
|
||||
*/
|
||||
protected function redirectTo($request): ?string
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
// Cek guard admin dulu
|
||||
if ($request->is('admin/*')) {
|
||||
return route('admin.login');
|
||||
}
|
||||
|
||||
// Default kalau bukan admin (misalnya guru/siswa)
|
||||
return route('login');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('admins', function (Blueprint $table) {
|
||||
$table->rememberToken()->after('password');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('admins', function (Blueprint $table) {
|
||||
$table->dropColumn('remember_token');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -174,3 +174,66 @@ @media (max-width: 600px) {
|
|||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==================== */
|
||||
/* TOAST & REMEMBER CSS */
|
||||
/* ==================== */
|
||||
|
||||
/* Toast Notifikasi Error */
|
||||
.toast-error {
|
||||
position: relative;
|
||||
margin-bottom: 1rem;
|
||||
background-color: #e62727; /* soft red pastel */
|
||||
color: #fff;
|
||||
padding: 10px 14px;
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
animation: fadeInOut 3.5s ease forwards;
|
||||
font-size: 15px;
|
||||
font-family: "Istok Web", sans-serif;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
@keyframes fadeInOut {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
10% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
90% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remember Me Styling */
|
||||
.remember-wrapper {
|
||||
margin-top: 0.3rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center; /* <— ubah dari flex-start jadi center */
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.remember-label {
|
||||
font-size: 15px;
|
||||
color: #333;
|
||||
font-family: "Istok Web", sans-serif;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.remember-label input {
|
||||
transform: scale(1.1);
|
||||
accent-color: #2196f3; /* biru lembut biar nyatu */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,13 @@
|
|||
<div class="signin-container">
|
||||
<h1 class="signin-title">SIGN IN ADMIN</h1>
|
||||
|
||||
{{-- Toast Notifikasi Error --}}
|
||||
@if ($errors->any())
|
||||
<div id="toast-error" class="toast-error">
|
||||
{{ $errors->first() }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('admin.login.submit') }}">
|
||||
@csrf
|
||||
<div class="form-card">
|
||||
|
|
@ -16,7 +23,8 @@
|
|||
{{-- Username --}}
|
||||
<div class="input-group">
|
||||
<img src="{{ asset('icons/username.svg') }}" alt="Username icon" class="input-icon">
|
||||
<input type="text" name="username" class="form-input" placeholder="Username" required>
|
||||
<input type="text" name="username" class="form-input" placeholder="Username" required
|
||||
value="{{ old('username') }}">
|
||||
</div>
|
||||
|
||||
{{-- Password --}}
|
||||
|
|
@ -30,6 +38,14 @@
|
|||
</button>
|
||||
</div>
|
||||
|
||||
{{-- Remember Me --}}
|
||||
<div class="remember-wrapper">
|
||||
<label class="remember-label">
|
||||
<input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}>
|
||||
<span>Remember me</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<button type="submit" class="submit-btn">SIGN IN</button>
|
||||
|
|
@ -54,6 +70,12 @@
|
|||
: "{{ asset('icons/hide.svg') }}";
|
||||
eyeIcon.alt = isVisible ? "Show password" : "Hide password";
|
||||
});
|
||||
|
||||
// Auto hide toast notification
|
||||
const toast = document.getElementById('toast-error');
|
||||
if (toast) {
|
||||
setTimeout(() => toast.remove(), 4000);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
|||
Loading…
Reference in New Issue