Oturum açtıktan sonra bir URL'ye yönlendirmede sorun yaşıyorum. Durum, bir kullanıcının bir blog gönderisini ziyaret etmesi ve yorum eklemeden önce giriş yapması gerektiğidir. Böylece kullanıcı giriş bağlantısını tıklar ve "auth/login" e giriş yapar ve her zaman "/ home" a yönlendirilir.Oturum açıldıktan sonra URL'ye laravel yönlendirmesi
Ben kullanıcı bir url "? Auth/giriş yönlendirme = url/to/blogpost"
gibi ayarlanır blogpost yönlendirilmek istiyorum ben şu Katman:
uygulama \ http Ara Katman \ \
Ara Katman \ kimliğini doğrulamak \<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
class RedirectIfAuthenticated
{
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
return redirect('/home');
}
return $next($request);
}
}
app \ http RedirectIfAuthenticated Eğer laravel 5'ten standart kimlik doğrulaması kullanıyorsanız
<?php namespace App\Http\Middleware; use Closure; use Illuminate\Contracts\Auth\Guard; class Authenticate { /** * The Guard implementation. * * @var Guard */ protected $auth; /** * Create a new filter instance. * * @param Guard $auth * @return void */ public function __construct(Guard $auth) { $this->auth = $auth; } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect()->guest('auth/login'); } } return $next($request); } }
http://stackoverflow.com/questions/15389833/laravel-redirect-back-to-original-destination-after-login – xdevnull