I have this form working on Localhost but when I upload to my shared hosting they throw VerifyCsrfToken.php line 67.
Here the code:
<form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}">
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password">
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<div class="checkbox">
<label>
<input type="checkbox" name="remember"> Remember Me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
<i class="fa fa-btn fa-sign-in"></i> Login
</button>
<a class="btn btn-link" href="{{ url('/password/reset') }}">Forgot Your Password?</a>
FB Login
</div>
</div>
</form>
I added this: <meta name="csrf-token" content="{{ csrf_token() }}" /> in to my head tags, but it's not working. The token is okay, appears on the form when I inspect with Google Chrome Inspector. If someone can help on this I am really stuck here.
Check your session directory for correct permissions, it might be help.
rm -f {your_web_app}/storage/framework/sessions/*
You properly have trouble with session storage
Solution 1: Use database session driver instead of file session driver
- In .env
SESSION_DRIVER=database
- Run command
php artisan session:table
- Then
php artisan migrate
Test again
Solution 2: Continue using file session driver. Make sure you have writing permission on storage folder. Try
chmod 755 -R storage
I am using this method.
<input type="hidden" name="_token" value="{{ session()->getToken() }}">
In your view blade.
Related
I am implementing authentication in my Laravel application, the register and logout routes are working perfectly fine, but the login form is not working. I'm not getting any error, but when I click the logi button it doesn't go anywhere.
Here is my login.blade.php :
#extends('layouts.app')
#section('title', 'Login')
#section('content')
<form class="form-horizontal form-material" id="loginform" method="POST" action="{{ route('login') }}>
#csrf
<h3 class="text-center m-b-20">Sign In</h3>
<div class="form-group ">
<div class="col-xs-12">
<input required="" id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" placeholder="Enter your Email" name="email" value="{{ old('email') }}" required autofocus> </div>
#if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
<div class="form-group">
<div class="col-xs-12">
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" placeholder="Enter your Password" required>
#if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<div class="col-md-12">
<div class="d-flex no-block align-items-center">
<div class="custom-control custom-checkbox">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="remember">
{{ __('Remember Me') }}
</label>
</div>
<div class="ml-auto">
<i class="fas fa-lock m-r-5"></i>{{ __('Forgot Your Password?') }}
</div>
</div>
</div>
</div>
<div class="form-group text-center">
<div class="col-xs-12 p-b-20">
<button class="btn btn-block btn-info btn-rounded" type="submit">{{ __('Login') }}</button>
</div>
</div>
<div class="form-group m-b-0">
<div class="col-sm-12 text-center">
Don't have an account? <b>Sign Up</b>
</div>
</div>
</form>
#endsection
These are my login routes:
$this->get('admin/login', 'Auth\LoginController#showLoginForm')->name('login');
$this->post('admin/login', 'Auth\LoginController#login');
Does anyone know where I messed up?
You can try implementing the standard auth routing wrapped in a prefix to give you want you want:
Route::group(['prefix' => 'admin'], function () {
Auth::routes();
});
That way you do not have to worry about the route names being different from the docs :)
I have got the issue in Laravel of The page has expired due to inactivity.
Please refresh and try again. I have also check {{ csrf_field() }} and its is fine but issue is still there. I have also checked about try cache, view, route clear command but again bad luck. Can any one suggest me what is the issue.
Form Code :
<form id="loginform" class="form-vertical" method="POST" action="{{ route('login') }}">
{{ csrf_field() }}
<div class="control-group normal_text"> <h3><img src="{{ asset('img/logo.png') }}" alt="Logo" /></h3></div>
<div class="control-group">
<div class="controls">
<div class="main_input_box">
<span class="add-on bg_lg"><i class="icon-user"> </i></span>
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus placeholder="Username"/>
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<div class="main_input_box">
<span class="add-on bg_ly"><i class="icon-lock"></i></span>
<input id="password" type="password" class="form-control" name="password" required placeholder="Password" />
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
</div>
<div class="form-actions">
<span class="pull-left">Lost password?</span>
<span class="pull-right"><button type="submit" class="btn btn-success">Login</button></span>
</div>
</form>
I have solved.
I have tried all steps from https://www.5balloons.info/fixed-page-expired-due-inactivity-laravel-5/ but the issue is still on there.
The main issue was my browser catch setting.
see below screenshot for more idea.
I'm trying to render the view with the form reset password and laravel can't do it. Don't have errors but view is all white. If i change the view to other with a simple h1 laravel render it.
So, I guess the problem is with the token.
The route is this:
Route::get('/password/reset/{token}','Auth\AdminResetPasswordController#showResetForm')->name('admin.password.reset');
The controller function this:
public function showResetForm(Request $request, $token = null)
{
return view('auth.passwords.reset-admin')->with(
['token' => $token, 'email' => $request->email]
);
}
And the view file is at
/resources/views/auth/passwords/reset-admin.blade.php
Thanks a lot.
At the end of the render process execute this function:
public function handleShutdown()
{
if (! is_null($error = error_get_last()) && $this->isFatal($error['type'])) {
$this->handleException($this->fatalExceptionFromError($error, 0));
}
}
Blade content:
#extends('backend.public.includes.head')
#section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">ADMIN Reset Password</div>
<div class="panel-body">
#if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
#endif
<form class="form-horizontal" role="form" method="POST" action="{{ route('admin.password.request') }}">
{{ csrf_field() }}
<input type="hidden" name="token" value="{{ $token }}">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ $email or old('email') }}" required autofocus>
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required>
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
#if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Reset Password
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
Extrainfo:
Take the scripts, but not render the form.
Error on error.loc
2017/07/14 11:19:35 [error] 5048#5048: *1 FastCGI sent in stderr: "PHP message: PHP Warning: require(/home/vagrant/Code/name/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/Code/name/bootstrap/autoload.php on line 17
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /home/vagrant/Code/name/public/index.php:0
PHP message: PHP 2. require() /home/vagrant/Code/name/public/index.php:22
If i put something like alskdaslkd on the view, it render it.
SOLVED
The problem is i use extend to head (where i have all the scripts) but in /layouts/default is where i define my "structure" with #yield('content') so if i put #extends('backend.public.layouts.default') on the top of the blade, i can use #section('content')
I'm displaying a form where, if the user is not authenticated, there's a button that will launch a modal login form.
I enter valid credentials and experience a MethodNotAllowedHttpException. However, I am authenticated. In another tab (or by hitting back and reloading)
(1/1) MethodNotAllowedHttpException
in RouteCollection.php (line 251)
at RouteCollection->methodNotAllowed(array('POST'))
in RouteCollection.php (line 238)
My modal form:
<form class="form-horizontal" role="form" method="POST" action="{{ route('login') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email"
value="{{ old('email') }}" required autofocus>
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong></span>
#endif
</div></div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required>
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong></span>
#endif
</div></div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<div class="checkbox">
<label> <input type="checkbox"
name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me</label></div></div></div>
<div class="form-group">
<div class="col-md-8 col-md-offset-4">
<button type="submit" class="btn btn-primary">Login</button>
<a href="#reset_modal" class="btn btn-link" data-toggle="modal" data-dismiss="modal" data-target="#reset_modal">
Forgot Your Password?</a></div></div></form>
Relevant portion of my SessionController.php:
public function store (Request $request) {
if (! auth()->attempt(request(['email', 'password']))) {
return back();
}
return redirect('/dashboard');
}
Relevant route:
Route::post('/login', 'SessionController#store');
I cannot seem to narrow down the cause to the exception. Help would be appreciated.
This was a case of an issue due to feedback attempting to post back to the page (originated with a post form) via back which is a GET string. So the route error was due to that.
I wish there was a way to redirect back using POST.
I've following this Blog for multi table authentication. I downloaded the project as it is and run the project. Everything works but validation is not working. Now message showing while I post an empty form.
Here is the code:
<form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Name</label>
<div class="col-md-6">
<input type="text" class="form-control" name="name" value="{{ old('name') }}">
#if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input type="email" class="form-control" name="email" value="{{ old('email') }}">
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password">
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Confirm Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password_confirmation">
#if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
<i class="fa fa-btn fa-user"></i>Register
</button>
</div>
</div>
</form>
According to the code error should be shown. I don't understand why its not working.
There is no validation rules or incorrect validation rules in your post controller.