Laravel 5中的自定义身份验证,登录并以相同的形式注册


Custom auth in Laravel 5 with login and register in the same form

如何在同一页面中执行相同的登录和注册表单。喜欢 pinterest.com并在注册后立即登录用户。

我不知道如何进行手动身份验证,只是默认Auth'AuthController

我有这个控制器,模型和视图..给我抛出错误 MethodNotAllowedHttpException in compiled.php line 7717:

型号:发布.php

class Publish extends Model implements AuthenticatableContract, CanResetPasswordContract{
    //
    use Authenticatable, CanResetPassword;
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'user_profiles';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['email', 'password'];
    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = ['password', 'remember_token'];
}
控制器

:发布控制器

use App'Http'Controllers'Controller;
use App'Publicar;
use Auth;
use Request;
class PublishController extends Controller {

    public function index()
    {
        return view('partials.loginCreate', compact('publish'));

    }

     public function authenticate()
    {
        if (Auth::attempt(['email' => $email, 'password' => $password]))
        {
            return redirect()->intended('dashboard');
        }
    }

查看: 登录.刀片.php

<form class="form-horizontal" role="form" method="POST" action="{{ url('/publish/authenticate') }}">
                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                        <div class="form-group">
                            <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') }}">
                            </div>
                        </div>

路线.php

Route::get('publish', 'PublishController@index');
Route::get('publish/authenticate', 'PublishController@authenticate');
Route::get('publishLogout', 'PublishController@destroy');

更改路线

Route::get('publish/authenticate', 'PublishController@authenticate');

Route::post('publish/authenticate', 'PublishController@authenticate');

因为您在调用身份验证方法时正在发布一些数据,但您选择的路由方法是 get,因此您会收到 MethodNotAllow 异常