多个标题问题

时间:2015-06-03 08:06:09

标签: laravel laravel-5 laravel-routing

<?php namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Http\Requests\RegisterRequest;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\Registrar;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

use App\Http\Requests\LoginRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\URL;


class AuthController extends Controller {

	/*
	|--------------------------------------------------------------------------
	| Registration & Login Controller
	|--------------------------------------------------------------------------
	|
	| This controller handles the registration of new users, as well as the
	| authentication of existing users. By default, this controller uses
	| a simple trait to add these behaviors. Why don't you explore it?
	|
	*/

	use AuthenticatesAndRegistersUsers;

    /**
     * For redirect after registeration
     * @return mixed
     */
    public function redirectPath()
    {


//        return property_exists($this, 'redirectTo') ? $this->redirectTo : '/user/profile/';
        //return property_exists($this, 'redirectTo') ? $this->redirectTo : '/';
        return Redirect::intended('/');
    }


    /**
     * Create a new authentication controller instance.
     *
     * @param  \Illuminate\Contracts\Auth\Guard $auth
     * @param  \Illuminate\Contracts\Auth\Registrar $registrar
     * @return \App\Http\Controllers\Auth\AuthController
     */
	public function __construct(Guard $auth, Registrar $registrar)
	{
		$this->auth = $auth;
		$this->registrar = $registrar;

		$this->middleware('guest', ['except' => 'getLogout']);
	}


    /**
     * Handle a login request to the application.
     *
     * @param  LoginRequest  $request
     * @return Response
     */
    public function postLogin(LoginRequest $request)
    {
        if ($this->auth->attempt($request->only('email', 'password')))
        {
            if(Auth::user()->is_admin)
                return redirect('/admin');
            else {
                return Redirect::intended('/');
            }

        }

        return redirect('auth/login')->withErrors([
            'email' => 'The credentials you entered did not match our records. Try again?',
        ]);
    }

}

我在注册后将用户重定向到目标网址,但我收到以下错误。

Header may not contain more than a single header, new line detected

这是AuthController中的代码。

public function redirectPath()
{
    return Redirect::intended('/');
}

以下是Authenticate类中的代码。

public function handle($request, Closure $next)
    {
        if ($this->auth->guest())
        {
            if ($request->ajax())
            {
                return response('Unauthorized.', 401);
            }
            else
            {
                return redirect()->guest('auth/register');
            }
        }

        return $next($request);
    }

我正在使用laravel 5

0 个答案:

没有答案