我继续别人的代码。 并且一直试图解决它。
它是一个使用laravel的运行系统。 然后我将系统移动到另一台计算机。
我设法在此guide之后使用xampp进行设置 但在我登录后,它一直给我无效登录。香港专业教育学院检查数据库,凭证是否正确。
我真的不知道如何追踪它出错的地方,但我设法得到这个痕迹(我更改了数据库名称);密码丢失了。
错误名称
PDOException in PDOConnection.php line 43:
SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database
'myapp'
错误是由于我更改了db用户名。 ;) 我试图弄清楚为什么当它移动到另一台机器时它不起作用。 如果散列密码隐藏在跟踪中,我猜我所分享的跟踪将没有任何帮助。任何想法我接下来应该做什么? :_I
更新 的LoginController
更新 按要求登录LoginController.php
<?php
namespace App\Http\Controllers\Frontend\MemberAuth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Auth;
use Hesto\MultiAuth\Traits\LogsoutGuard;
use Illuminate\Http\Request;
use App\Model\Member\Member;
use Response;
use App\Exceptions\Handler;
use App;
use App\Traits\ValidateCaptchaTrait;
use Lang;
use Carbon\Carbon;
class LoginController extends Controller
{
use AuthenticatesUsers, LogsoutGuard {
LogsoutGuard::logout insteadof AuthenticatesUsers;
}
use ValidateCaptchaTrait;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->redirectTo = route('frontend.memberprofile.account');
$this->middleware('member.guest', ['except' => 'logout']);
}
/**
* Override the username method used to validate login
*
* @return string
*/
public function username()
{
return 'agent_id';
}
/**
* Show the application's login form.
*
* @return \Illuminate\Http\Response
*/
public function showLoginForm()
{
return view('frontend.member.auth.login');
}
/**
* Get the guard to be used during authentication.
*
* @return \Illuminate\Contracts\Auth\StatefulGuard
*/
protected function guard()
{
return Auth::guard('member');
}
public function login(Request $request)
{
// Validate Captcha
if(!$this->isValidCaptcha()){
return redirect()->back()->withErrors(['captcha' => 'Invalid Captcha.'])->withInput();
}
$this->validateLogin($request);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
if ($this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
if ($this->attemptLogin($request)) {
return $this->sendLoginResponse($request);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
$this->incrementLoginAttempts($request);
return $this->sendFailedLoginResponse($request);
}
protected function credentials(Request $request)
{
// return $request->only($this->username(), 'password') ;
return array_merge($request->only($this->username(), 'password'), ['active' => 1]);
}
/**
* The user has been authenticated.
*
* @param \Illuminate\Http\Request $request
* @param mixed $user
* @return mixed
*/
protected function authenticated(Request $request, $user)
{
//
if(!is_null( $user )){
$user->lastlogin = Carbon::now();
$user->save();
}
return redirect()->intended($this->redirectPath());
}
}
更新2
<form class="form-horizontal" role="form" method="POST" action="{{ route('mem.lPost') }}"> {{ csrf_field(=) }}
答案 0 :(得分:0)
确保在.env文件中正确指定了数据库服务器的用户名和密码。在您的错误中,似乎您将用户名设置为“”,因此它表示拒绝访问用户''@ localhost'。 编辑.env文件
DB_DATABASE=yourDBname
DB_USERNAME=root (or whatever your usrname), there is no possibly here to be null
DB_PASSWORD=yourpassword
答案 1 :(得分:0)
如果您正在使用<div class="row form-group m-form__group m-login__form-sub">
<div class="col m--align-left">
<?php echo $this->Form->input('agree', array(
'type'=>'checkbox','label'=>'I Agree The'));?>
<a href="#" class="m-link m-link--focus">terms and conditions</a>
</div>
,请检查您的配置文件或.env
文件。输入正确的凭据,您就可以了。尝试使用默认设置:
laravel 5.*
<强>更新强>
如果您更改了应用程序的db database = myapp
username =
password = root
host = localhost
,那么存储在数据库中的加密数据将不再有效,例如app key
,除非您将passwords
放回原处。因此,帐户的解决方案是使用app key
帮助程序或bcrypt
创建或更新密码,以便Hash::make
能够正确存储新的passwords
。
包含您的链接:
https://laracasts.com/discuss/channels/general-discussion/app-key
更新2:
注意: 您可以将它放在您的主页方法所在的控制器中。
app key
答案 2 :(得分:0)
示例环境文件
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=yourDB
DB_USERNAME=root
DB_PASSWORD=yourpassword
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
如果在命令
下面运行了一些缓存问题