【问题标题】:Laravel 5.3 Password Reset error without any error logLaravel 5.3 密码重置错误,没有任何错误日志
【发布时间】:2017-01-23 14:48:43
【问题描述】:

我正在使用默认的 laravel 身份验证方法。
当我尝试重置密码时,一切正常,直到我尝试发送重置表单。

此时,它只是向我发送任何日志的错误。
我知道发送了一个错误,因为我将以下行添加到 App\Exceptions\handler.php

public function report(Exception $exception)
{
    Artisan::call('sms:basic');

    parent::report($exception);
}

所以,我收到了发生错误的通知。我没有登录,新密码无效。

发生这种情况时,laravel.log 文件为空。所以我不知道为什么不起作用。

有我使用的路线:

Auth::routes();

有视图文件。

@extends('layouts.public')

@section('content')

        <!-- RESET FORM -->
        <!--===================================================-->
        <div class="cls-content">
            <div class="cls-content-sm panel">
                <div class="panel-body background-black fix-margin-top">
                    <div class="text-left"><img style="height: 90px; width: auto;margin-left: -25px;" src="{{ url('/img/logoTorqueWhite.svg') }}" alt="" class=""></div>
                </div>
            </div>
            <div class="cls-content-sm panel ">
                <div class="panel-body fix-margin-top">
                    <div class="pull-right"><a class="black" href="{{ url('/') }}"><i class="fa fa-times"></i></a></div>
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 vert-line">
                            <p>Réinitialiser votre mot de passe</p>
                            @if (session('status'))
                                <div class="alert alert-success">
                                    {{ session('status') }}
                                </div>
                            @endif
                            <form method="POST" role="form" action="{{ url('/password/reset') }}">
                                <div class="form-group text-left{{ $errors->has('email') ? ' has-error' : '' }}">
                                    <label>Courriel</label>
                                    <input id="email" type="email" name="email" class="form-control" placeholder="" value="{{ old('email') }}">
                                    @if ($errors->has('email'))
                                        <span class="form-control">
                                            <strong>{{ $errors->first('email') }}</strong>
                                        </span>
                                    @endif
                                </div>

                                <div class="form-group text-left{{ $errors->has('password') ? ' has-error' : '' }}">
                                    <label>Mot de passe</label>
                                    <input type="password" name="password" class="form-control" placeholder="">
                                    @if ($errors->has('password'))
                                        <span class="form-control">
                                            <strong>{{ $errors->first('password') }}</strong>
                                        </span>
                                    @endif
                                </div>

                                <div class="form-group text-left{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
                                    <label>Confirmer le mot de passe</label>
                                    <input type="password" name="password_confirmation" class="form-control" placeholder="">
                                    @if ($errors->has('password_confirmation'))
                                        <span class="form-control">
                                            <strong>{{ $errors->first('password_confirmation') }}</strong>
                                        </span>
                                    @endif
                                </div>

                                <div class="col-xs-12 no-padding">
                                    <div class="form-group text-right">
                                        <input name="reset" type="submit" class="btn btn-torque" value="RÉINITIALISER">
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="col-xs-12 col-sm-4">
                            <div class="valign text-right">
                                <p>Contactez-nous<br>
                                (819) 679-2944<br>
                                info@torquemanagement.ca</p>
                            </div>
                        </div>
                    </div>
                    <div class="row text-left">
                        {{--<div class="col-xs-12">
                        Vous avez oublié votre mot de passe? <a href="/password/reset">Cliquez ici</a><br>
                        Vous n'avez pas encore de compte Torque? Créé un compte
                        </div>--}}
                    </div>
                </div>
            </div>
        </div>
        <!--===================================================-->
@endsection

我在其他地方看到有人要求添加这条路线:

Route::get('test', function(){
    dd ( bcrypt('raw_password') == "encrypted_password_in_db");
});

它返回给我假,而那些人说它应该返回真。 对此没有其他解释,但也许它可以帮助你帮助我。我真的不知道这是什么意思。

【问题讨论】:

  • 登录后是否尝试重设密码?
  • 我在尝试重置时已注销。我可以在使用自定义更改密码表单登录时更改密码。

标签: php laravel-5.3


【解决方案1】:

当你保存新密码时使用

Hash::make('newpassword')

它会工作之后:

Route::get('test', function(){
    dd (Hash::check('raw_password', 'encrypted-password'));
});

Laravel 总是使用随机加盐密码,所以你不能用 == 来检查它

【讨论】:

  • 当我尝试你的代码行时,我得到了错误的结果。
  • 另外,我认为 Hashids 的安全性比 bcrypt 低?你可以做一个 Hash::decode('anything'),而不是当你使用 bcrypt 时,它没有内置的解码。
猜你喜欢
  • 2016-07-06
  • 2016-07-11
  • 1970-01-01
  • 1970-01-01
  • 2017-05-08
  • 2017-08-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多