Php 可能在flash消息中有链接
我的工作是在登录前检查用户是否处于活动状态 这是我当前的登录代码Php 可能在flash消息中有链接,php,laravel,Php,Laravel,我的工作是在登录前检查用户是否处于活动状态 这是我当前的登录代码 public function login(Request $request) { // Validate the login request $this->validateLogin($request); //Check if user has surpassed their allowed login attempts //Keyed by th
public function login(Request $request)
{
// Validate the login request
$this->validateLogin($request);
//Check if user has surpassed their allowed login attempts
//Keyed by the username and IP address of the client making
//the request.
if ($this->hasTooManyLoginAttempts($request)){
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
// Attempt the login of the user.
$username = $request->get('username');
$password = $request->get('password');
$remember = $request->get('remember');
if($this->auth->attempt([
'username' => $username,
'password' => $password,
'activated' => 1
],$remember == 1 ? true : false)) {
if($this->guard()->user()->activated){
//Success: clear the login attempts session and redirect
//user to the user dashboard.
$request->session()->regenerate();
$this->clearLoginAttempts($request);
return redirect()->action('Front\PagesController@index');
}else{
//Not Activated redirect to login and kick them out
$this->guard()->logout();
$request->session()->flush();
$request->session()->regenerate();
return redirect('login')
->with('activation_response', 'action.danger');
}
}
else{
//Fail: If login attempt was unsuccessful, increment the number of attempts
//to login and redirect user back to login form, if user surpasses the maximum
//number of attempts user will be locked out for a certain amount of time.
$this->incrementLoginAttempts($request);
return redirect()->back()
->with('message','Incorrect username or password')
->with('status','danger')
->withInput();
}
}
在检查用户是否未激活时,我想显示一条闪光消息,告诉他们帐户未激活,但我想包括一个指向“重新发送激活”页面的链接
我的partials文件夹中也有这个,名为activation_response.blade.php
<a href="{{ url('/activation/resend') }}" class="new-account">Resend activation code</a>
我这样做的尝试不起作用,有没有办法
我也安装了laracasts/flash软件包
正在寻找如何完成此任务的一些方向。控制器:
$errors = ['activation_response' => 'You are not an active user. ' . link_to(url('activation/resend'), 'Click here') . ' to resend activation code'];
return redirect()->back()
->withInput($request->only($this->username(), 'remember'))
->withErrors($errors);
视图:
@if(session()->has('errors')&&&$errors->first('activation\u response'))
{!!$errors->first('activation\u response')!!}
@恩迪夫
确保将HTML响应包装在
{!!!!}
标记中,以呈现未扫描的数据 由于您使用的是flash软件包,因此可以尝试类似于flash()->message('message'.route('foo')。'message'.)之类的方法。
。我以前从未亲自尝试过。
@if(session()->has('errors') && $errors->first('activation_response'))
<div class="alert alert-danger" role="alert">
{!!$errors->first('activation_response')!!}
</div>
@endif