身份验证和代码,电子邮件确认Laravel 5.1

时间:2015-12-02 19:11:12

标签: authentication laravel-5.1 laravel-routing

This is the screenshot of the error message我对使用此代码登录感到有点沮丧。我按照本教程 - Laravel authentication, logging in.

这是我的注册页面:

@extends('layouts.master')

    @section('title')
        Create User
    @stop

    <link href="{!! asset('css/style.css') !!}" media="all" rel="stylesheet" type="text/css" />

    @section('body')
        {!! Form::open(array('action' => 'UserController@store')) !!}

            @if (count($errors) > 0)
                <div class="alert alert-danger">
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif
            <DIV align="center"><SPAN class="div-header">MEMBER REGISTRATION</SPAN></DIV>
            <TABLE>
                <TH>FIELDS</TH><TH>DESCRIPTIONS</TH>
                <TR><TD>{!! Form::text('firstname', '', ['class'=>'css-input', 'placeholder'=>'enter firstname' ]) !!}</TD><TD class="font-description"><SPAN><STRONG><I>FIRSTNAME</I></STRONG></SPAN> field requests the input of your surname or family name. Only <SPAN><STRONG><I>alphabets</I></STRONG></SPAN> are accepted as valid inputs. </TD></TR>
                <TR><TD>{!! Form::text('lastname', '', ['class'=>'css-input', 'placeholder'=>'enter lastname']) !!}</TD><TD class="font-description"><SPAN><STRONG><I>LASTNAME</I></STRONG></SPAN> field requests the input of your real or given name, not a nickname. Only <SPAN><STRONG><I>alphabets</I></STRONG></SPAN> are accepted as valid inputs. </TD></TR>
                <TR><TD>{!! Form::email('email', '', ['class'=>'css-input', 'placeholder'=>'myemail@domain.com']) !!}</TD><TD class="font-description"><SPAN><STRONG><I>EMAIL</I></STRONG></SPAN> field requests the input of your email address, It must have been opened before this registration can be effected. If you intend opening, kindly open a <a href="https://accounts.google.com/SignUp?continue=https%3A%2F%2Faccounts.google.com%2Fb%2F0%2FServiceNotAllowed%3Fservice%3Dmail%26continue%3Dhttps%253A%252F%252Fmail.google.com%252Fmail%252Fu%252F0%252F">Gmail</a>, <a href="https://edit.yahoo.com/registration?.lang=en-US&.intl=us&.done=https%3A%2F%2Fmail.yahoo.com&.src=ym&fsredirect=1&fs=SO0HWeyHafAMj8FE0yNh5Xi_09TVLzjjjrbNyBPC.Ln5RNTM7KJv1zpxl4x.syDl2GLm5HLA">Yahoo</a> , <a href="https://signup.live.com/signup?sf=1&id=38936&ru=https%3a%2f%2faccount.live.com%2f%3fwa%3dwsignin1.0&tw=0&fs=0&kv=0&cb=&cbcxt=&wp=SAPI&wa=wsignin1.0&wreply=https%3a%2f%2faccount.live.com%2f%3fwa%3dwsignin1.0&bk=1448545061&uiflavor=web&uaid=cbd99572ef854726ba19563bb35be01d&mkt=EN-US&lc=1033&lic=1">Microsoft</a> or any other one as appropriate.</TD></TR>
                <TR><TD>{!! Form::text('username', '', ['class'=>'css-input', 'placeholder'=>'my username']) !!}</TD><TD class="font-description"><SPAN><STRONG><I>USERNAME</I></STRONG></SPAN> field requests the input of a nickname or any other name you  with to be referred with. Only <SPAN><STRONG><I>alphabets and figures</I></STRONG></SPAN> are accepted as valid inputs.</TD></TR>
                <TR><TD>{!! Form::password('password', ['class'=>'css-input', 'placeholder'=>'password']) !!}</TD><TD class="font-description"><SPAN><STRONG><I>PASSWORD</I></STRONG></SPAN> field requests the input of a chosen secret code. A minimum of 8 characters is adviced for a secure account. A combination of<SPAN><STRONG><I> alphabets, figures and special characters</I></STRONG></SPAN> are accepted as valid inputs.</TD></TR>
                <TR><TD>{!! Form::password('password_confirmation', ['class'=>'css-input', 'placeholder'=>'repeat password']) !!}</TD><TD class="font-description"><SPAN><STRONG><I>REPEAT PASSWORD</I></STRONG></SPAN> field requests the re-input of the password above. A minimum of 8 characters is adviced for a secure account. A combination of<SPAN><STRONG><I> alphabets, figures and special characters</I></STRONG></SPAN> are accepted as valid inputs.</TD></TR>
                <TR><TD>{!! Form::submit('SUBMIT', ['class'=>'css-button']) !!}</TD><TD><div id="divContainer"><div class="theDiv">{!! Form::submit('FACEBOOK', ['class'=>'css-viewdetailbutton']) !!}</div><div class="theDiv">{!! Form::submit('YAHOO', ['class'=>'css-updatebutton']) !!}</div><div class="theDiv">{!! Form::submit('GOOGLE', ['class'=>'css-deletebutton']) !!}</div></div><div class="theDiv">{!! Form::submit('PASSWORD REC', ['class'=>'css-deletebutton']) !!}</div></TD></TR>
            </TABLE>
        {!! Form::close() !!}
    @stop

路线:

Route::resource('users', 'UserController');

Route::get('auth/login/{confirmationCode}', ['as' => 'verifypage', 'uses' => 'UserController@confirm']);

Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');

// Registration routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');

控制器:

public function loginUser()
    {
        $rules = [
            //'username' => 'required|exists:users',
            'email' => 'required|exists:users',
            'password' => 'required'
        ];

        $input = Input::only('username', 'email', 'password');

        $validator = Validator::make($input, $rules);

        if($validator->fails())
        {
            return Redirect::back()->withInput()->withErrors($validator);
        }

        $credentials = [
           // 'username' => Input::get('username'),
            'email' => Input::get('email'),
            'password' => Input::get('password'),
            'confirmed' => 1
        ];

        if ( ! Auth::attempt($credentials))
        {
            return Redirect::back()
                ->withInput()
                ->withErrors([
                    'credentials' => 'We were unable to sign you in.'
                ]);
        }

        Flash::message('Welcome back!');

        //return Redirect::index();
        return view('userpages.index');
    }

此代码已执行但仅保留路由问题。我很惊讶它找不到索引页面或者我做错了什么。它执行是因为我可以在db中看到已确认列的值在db中更改为1。我究竟做错了什么。感谢您的有效投入。请完整的代码片段,我们将不胜感激。 This is the screenshot for the error I'[![This screenshot confirms the code executed by confirming the user confirm status changed to 1获得2] 2

0 个答案:

没有答案