handle allert login

This commit is contained in:
baghizadizn 2025-11-11 10:10:00 +07:00
parent 1aaa24a4d7
commit 3a595abfd2
6 changed files with 326 additions and 210 deletions

View File

@ -49,6 +49,12 @@ class AuthenticatedSessionController extends Controller
{ {
$input = $request->all(); $input = $request->all();
// Manual validation check before proceeding
if (empty($input['email']) || empty($input['password'])) {
Session::flash('error', get_phrase('Email or password is empty. Please fill in all the required fields.'));
return redirect(route('login'))->withInput();
}
if (get_frontend_settings('recaptcha_status') == true && check_recaptcha($input['g-recaptcha-response']) == false) { if (get_frontend_settings('recaptcha_status') == true && check_recaptcha($input['g-recaptcha-response']) == false) {
Session::flash('error', get_phrase('Recaptcha verification failed')); Session::flash('error', get_phrase('Recaptcha verification failed'));

View File

@ -6,8 +6,11 @@ use Illuminate\Auth\Events\Lockout;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter; use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Illuminate\Support\Facades\Validator;
class LoginRequest extends FormRequest class LoginRequest extends FormRequest
{ {
@ -32,20 +35,48 @@ class LoginRequest extends FormRequest
]; ];
} }
public function messages()
{
return [
'email.required' => get_phrase('Email is required'),
'password.required' => get_phrase('Password is required'),
'email.email' => get_phrase('Please enter a valid email address'),
];
}
public function withValidator($validator)
{
$validator->after(function ($validator) {
if ($validator->failed()) {
Session::flash('error', get_phrase('Please fill in all the required fields correctly.'));
}
});
}
/** /**
* Attempt to authenticate the request's credentials. * Attempt to authenticate the request's credentials.
* *
* @throws \Illuminate\Validation\ValidationException * @throws \Illuminate\Validation\ValidationException
*/ */
public function authenticate(): void
public function authenticate()
{ {
$this->ensureIsNotRateLimited(); $this->ensureIsNotRateLimited();
// Custom validation before attempting login
if (empty($this->email) || empty($this->password)) {
Session::flash('error', get_phrase('Email or password is empty. Please fill in all the required fields.'));
throw ValidationException::withMessages([
'email' => '', // Empty message to avoid default validation messages
]);
}
if (!Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) { if (!Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey()); RateLimiter::hit($this->throttleKey());
Session::flash('error', get_phrase('Login failed. Please check your email and password.'));
throw ValidationException::withMessages([ throw ValidationException::withMessages([
'email' => trans('auth.failed'), 'email' => '', // Empty message to avoid default validation messages
]); ]);
} }

View File

@ -765,8 +765,8 @@ img {
.Userprofile .dropmenu-end a:hover svg path, .Userprofile .dropmenu-end a:hover svg path,
.Userprofile .dropmenu-end a:hover { .Userprofile .dropmenu-end a:hover {
color: #c664ff; color: var(--color-1);
fill: #c664ff; fill: var(--color-1);
} }
.Userprofile .dropmenu-end a i { .Userprofile .dropmenu-end a i {
@ -3179,7 +3179,7 @@ html .ui-button.ui-state-disabled:active {
} }
.c-card:hover .eBtn { .c-card:hover .eBtn {
background-image: linear-gradient( to right, #2f57ef 0%, #c664ff 51%, #c664ff 100%); background-image: linear-gradient(45deg, rgba(2, 25, 110, 1) 0%, rgba(2, 25, 110, 1) 13%, rgba(217, 217, 217, 1) 65%, rgba(255, 255, 255, 1) 98%);
background-size: 200% auto; background-size: 200% auto;
box-shadow: 0 0 20px #eee; box-shadow: 0 0 20px #eee;
transition: 0.5s; transition: 0.5s;
@ -4500,10 +4500,10 @@ html .ui-button.ui-state-disabled:active {
} }
.gradient-border-btn:hover { .gradient-border-btn:hover {
background-image: linear-gradient( to right, #2f57ef 0%, #c664ff 51%, #c664ff 100%); background: #fff;
color: var(--color-white); background-position: right center;
color: #001151;
border-color: transparent; border-color: transparent;
background-position: center;
} }
.footer-widget h4 { .footer-widget h4 {
@ -4524,11 +4524,12 @@ html .ui-button.ui-state-disabled:active {
margin-bottom: 16px; margin-bottom: 16px;
font-size: 15px; font-size: 15px;
font-weight: 400; font-weight: 400;
transition: 0.5s; transition: font-weight 0.3s ease;
} }
.footer-widget ul li a:hover { .footer-widget ul li a:hover {
color: var(--color-1); transform: scale(1.02);
font-weight: 600;
} }
.newslater-bottom p { .newslater-bottom p {
@ -4599,6 +4600,12 @@ html .ui-button.ui-state-disabled:active {
font-size: 13px; font-size: 13px;
font-weight: 400; font-weight: 400;
color: #dedede; color: #dedede;
transition: all 0.3s ease;
}
.footer-policy li a:hover {
transform: scale(1.02);
color: #ffffff;
} }
.copyright-text { .copyright-text {
@ -5582,7 +5589,7 @@ ul.my-bootcamps li:nth-last-child(1) {
} }
.Userprofile .dropmenu-end a.bootcamp-menu-icon:hover svg path { .Userprofile .dropmenu-end a.bootcamp-menu-icon:hover svg path {
stroke: #c664ff; stroke: var(--color-1);
fill: none; fill: none;
} }

View File

@ -1,4 +1,5 @@
/*Font Size*/ /*Font Size*/
.text-20px { .text-20px {
font-size: 20px !important; font-size: 20px !important;
} }
@ -51,7 +52,9 @@
font-size: 8px !important; font-size: 8px !important;
} }
/*Bootstrap toaster*/ /*Bootstrap toaster*/
.search-box { .search-box {
position: relative; position: relative;
margin-bottom: 30px; margin-bottom: 30px;
@ -110,12 +113,7 @@
} }
.gradient { .gradient {
background-image: linear-gradient( background-image: inear-gradient(45deg, rgba(2, 25, 110, 1) 0%, rgba(2, 25, 110, 1) 13%, rgba(217, 217, 217, 1) 65%, rgba(255, 255, 255, 1) 98%);
to right,
#2f57ef 0%,
#c664ff 51%,
#c664ff 100%
);
transition: 0.5s; transition: 0.5s;
background-size: 200% auto; background-size: 200% auto;
box-shadow: 0 0 20px #eee; box-shadow: 0 0 20px #eee;
@ -123,7 +121,7 @@
.gradient:hover { .gradient:hover {
background-position: right center; background-position: right center;
color: #fff; color: #001151;
text-decoration: none; text-decoration: none;
} }
@ -327,11 +325,13 @@
width: 20px; width: 20px;
height: 20px; height: 20px;
} }
.playing-header-btns>a { .playing-header-btns>a {
min-height: 40px; min-height: 40px;
display: flex !important; display: flex !important;
align-items: center; align-items: center;
} }
.image-100 { .image-100 {
min-width: 100px !important; min-width: 100px !important;
width: 100px !important; width: 100px !important;
@ -387,6 +387,7 @@
border-radius: 50% !important; border-radius: 50% !important;
object-fit: cover !important; object-fit: cover !important;
} }
.max-w-auto { .max-w-auto {
max-width: auto; max-width: auto;
} }

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,10 @@
right: 20px; right: 20px;
cursor: pointer !important; cursor: pointer !important;
} }
.alert {
border-radius: 8px;
margin-bottom: 20px;
}
</style> </style>
@endpush @endpush
@section('content') @section('content')
@ -27,15 +31,25 @@
<p class="description">{{ get_phrase('See your growth and get consulting support!') }} </p> <p class="description">{{ get_phrase('See your growth and get consulting support!') }} </p>
<div class="form-group"> <div class="form-group">
<label for="email" class="form-label">{{ get_phrase('Email') }}</label> <label for="email" class="form-label">{{ get_phrase('Email') }}</label>
<input type="email" id="email" name="email" class="form-control" placeholder="{{ get_phrase('Your Email') }}"> <input type="email" id="email" name="email" class="form-control @error('email') is-invalid @enderror" placeholder="{{ get_phrase('Your Email') }}" value="{{ old('email') }}" required>
@error('email')
<div class="invalid-feedback">
{{ $message == 'validation.required' ? get_phrase('Email is required') : $message }}
</div>
@enderror
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="" class="form-label">{{ get_phrase('Password') }}</label> <label for="" class="form-label">{{ get_phrase('Password') }}</label>
<input type="password" id="password" name="password" class="form-control" placeholder="*********"> <input type="password" id="password" name="password" class="form-control @error('password') is-invalid @enderror" placeholder="*********" required>
@error('password')
<div class="invalid-feedback">
{{ $message == 'validation.required' ? get_phrase('Password is required') : $message }}
</div>
@enderror
</div> </div>
<div class="form-group mb-25 d-flex justify-content-between align-items-center remember-me"> <div class="form-group mb-25 d-flex justify-content-between align-items-center remember-me">
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="flexCheckChecked" checked> <input class="form-check-input" type="checkbox" name="remember" id="flexCheckChecked" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="flexCheckChecked">{{ get_phrase('Remember Me') }}</label> <label class="form-check-label" for="flexCheckChecked">{{ get_phrase('Remember Me') }}</label>
</div> </div>
<a href="{{route('password.request')}}">{{ get_phrase('Forget Password?') }}</a> <a href="{{route('password.request')}}">{{ get_phrase('Forget Password?') }}</a>
@ -50,11 +64,6 @@
<p class="mt-20">{{ get_phrase('Not have an account yet?') }} <p class="mt-20">{{ get_phrase('Not have an account yet?') }}
<a href="{{ route('register.form') }}">{{ get_phrase('Create Account') }}</a> <a href="{{ route('register.form') }}">{{ get_phrase('Create Account') }}</a>
</p> </p>
{{-- <p class="my-3">Login As -</p>
<button type="button" class="eBtn gradient w-100 mb-3 py-3 custom-btn" id="admin">Admin</button>
<button type="button" class="eBtn gradient w-100 mb-3 py-3 custom-btn" id="student">Student</button>
<button type="button" class="eBtn gradient w-100 mb-3 py-3 custom-btn" id="instructor">Instructor</button> --}}
</form> </form>
</div> </div>
</div> </div>
@ -64,10 +73,13 @@
@endif @endif
@endsection @endsection
@push('js') @push('js')
<script> <script>
"use strict"; "use strict";
function onLoginSubmit(token) {
document.getElementById("login-form").submit();
}
$(document).ready(function() { $(document).ready(function() {
$('.custom-btn').on('click', function(e) { $('.custom-btn').on('click', function(e) {
e.preventDefault(); e.preventDefault();
@ -83,7 +95,6 @@
$('#email').val('instructor@example.com'); $('#email').val('instructor@example.com');
$('#password').val('12345678'); $('#password').val('12345678');
} }
$('#login').trigger('click');
}); });
}); });
@ -99,10 +110,5 @@
} }
}); });
}); });
function onLoginSubmit(token) {
document.getElementById("login-form").submit();
}
</script> </script>
@endpush @endpush