简体   繁体   English

在生产中使用Laravel和Docker登录的问题

[英]Problem to get logged in with Laravel and docker on production

I have a Laravel application and I am currently working on integrating docker. 我有一个Laravel应用程序,目前正在集成docker。 The app runs perfectly locally but on production I simply can't log in. Every time I submit the log in form I get redirected to the log in form without any message of success nor failure. 该应用程序可在本地完美运行,但在生产环境中我根本无法登录。每次我提交登录表单时,都会重定向到登录表单,而不会收到任何成功或失败的消息。 I have realized that the request it reaches the controller it should but it does not reach the action. 我已经意识到,该请求应该到达控制器,但它没有达到动作。 I put a die command in the constructor and it worked but it didn't when I did the same in the first line of the controller's action. 我在构造函数中放置了一个die命令,它起作用了,但是当我在控制器操作的第一行中执行相同操作时,它没有起作用。

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

use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Monolog\Logger;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

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 AuthenticatesUsers;

/**
 * Where to redirect users after login / registration.
 *
 * @var string
 */
protected $redirectTo = '/';

/**
 * Create a new authentication controller instance.
 *
 * @return void
 */
public function __construct()
{
     // die('something') works here
    $this->middleware('guest', ['except' => ['logout', 'register', 'showRegistrationForm']]);
    // die('something') works here too
}

/**
 * Get a validator for an incoming registration request.
 *
 * @param  array  $data
 * @return \Illuminate\Contracts\Validation\Validator
 */
protected function validator(array $data)
{
    return Validator::make($data, [
        'rut' => 'required|max:30',
        'apellidos' => 'required|max:255',
        'name' => 'required|max:255',
        'email' => 'required|email|max:255|unique:users',
        'password' => 'required|confirmed|min:6',

    ]);
}

/**
 * Create a new user instance after a valid registration.
 *
 * @param  array  $data
 * @return User
 */
protected function create(array $data)
{
}

public function login(Request $request)
{
   //die('something'); doesn't work here
   $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);
}

}

I don't know if you still need it, but I had the same problem. 我不知道您是否仍然需要它,但是我有同样的问题。 You need to modify the paths in bootstrap/cache/config.php with the path that you set it for WORKDIR in Dockerfile. 您需要使用在Dockerfile中为WORKDIR设置的路径修改bootstrap / cache / config.php中的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM