Laravel login redirecting to login page after showing the below intermediate page
It happens only in the production server which is an oracle cloud instance with docker on it and working after server restart and again returns back after some hours.
My docker-compose file is
version: '3'
networks:
laravel:
services:
nginx:
build:
context: .
dockerfile: nginx.dockerfile
ports:
- "80:80"
volumes:
- .:/var/www/html:delegated
depends_on:
- PHP
networks:
- laravel
restart: always
MySQL:
image: mysql:5.7
tty: true
ports:
- "3306:3306"
environment:
MYSQL_USER: sdgf
MYSQL_DATABASE: sdgsdf
MYSQL_PASSWORD: dsfgsdf
MYSQL_ROOT_PASSWORD: dsfgsfg
SERVICE_TAGS: dev
SERVICE_NAME: MySQL
networks:
- laravel
volumes:
- ./data:/var/lib/mysql
restart: always
PHP:
build:
context: .
dockerfile: php.dockerfile
args:
- USER_ID=1001
- GROUP_ID=1001
volumes:
- .:/var/www/html:delegated
- ./docker/php/php.ini:/usr/local/etc/php/conf.d/custom.ini
ports:
- "9000:9000"
networks:
- laravel
restart: always
artisan:
build:
context: .
dockerfile: php.dockerfile
args:
- USER_ID=1001
- GROUP_ID=1001
volumes:
- .:/var/www/html:delegated
working_dir: /var/www/html
user: laravel
entrypoint: ['php', '/var/www/html/artisan']
networks:
- laravel
volumes:
mysql-data:
driver: local
php.ini file
max_execution_time = 120
;extension=php_gd2.dll
upload_max_filesize = 40m
post_max_size = 50m
memory_limit=1024M
Login method in Login controller
public function postAdminLogin(Request $request)
{
if (Auth::attempt(['email' => $request['email'], 'password' => $request['password'], 'role' => Constants::$ADMIN_USER])) {
return redirect()->route('adminHome');
}
if (Auth::attempt(['email' => $request['email'], 'password' => $request['password'], 'role' => Constants::$METER_READER])) {
return redirect()->route('adminHome');
}
// return redirect()->back()->with(['error' => 'Login Failed']);
}
I believe there is no mistake in the code and it was working perfectly in cpanel hosting for two years but the error comes up when hosting changed to cloud+docker setup. I also have a doubt if it is because of any session-related issues. I have tried both file and database session in laravel but nothing fixes the issue.
Please let me know if anyone comes across similar issues, thanks.
source https://stackoverflow.com/questions/70250594/laravel-login-redirecting-to-login-page
No comments:
Post a Comment