温馨提示:本文翻译自stackoverflow.com,查看原文请点击:其他 - Issue while trying to Login as admin laravel php
laravel-5 php

其他 - 尝试以管理员laravel php登录时出现问题

发布于 2020-03-31 23:37:42

我正在尝试为laravel应用程序设置本地调试环境。

一切都很好。今天,我删除了我的供应商文件夹,并安装了作曲家。首先,我开始获取错误有效载荷未定义。

之后,我将无法以管理员身份登录该应用程序。这不是较早发生的。我不知道为什么这会引发错误。

用户名:admin@admin.com密码:admin12345

在数据库中以哈希格式显示:$ 2y $ 10 $ BgzkwksC4dl8i3IWBGBGLudU1BjvK1giWf7wZeQm7dSOoxkaXfIAG

Hash::check($request->password, $admin->password) is always returning false.

这是我的代码:

public function login(Request $request){ 
        $validation = Validator::make($request->all(), [            
            'email'     => 'required|email',
            'password'  => 'required|min:5',            
        ]);
        if ($validation->fails()) { 
            return redirect()->back()->withErrors($validation)->withInput($request->only('email', 'remember'));   
        } 
        $admin = Admin::Where('email',$request->email)->first();
        if($admin){
            if (Hash::check($request->password, $admin->password)) {
                Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember);
                    Session::put('admin', $admin);
                return redirect()->intended(route('admin.home'));
            }else{
                return redirect()->back()->withErrors(['Wrong password.'])->withInput($request->only('email', 'remember'));
            }
        }
    return redirect()->back()->withInput($request->only('email', 'remember'));

    }

/ composer.json /

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.4.*",
        "laravel/socialite": "^3.0",
        "laravel/tinker": "~1.0",
        "maatwebsite/excel": "~2.1.0",
        "mobiledetect/mobiledetectlib": "^2.8",
        "nesbot/carbon": "^1.22",
        "pear/http_request2": "^2.3",
        "wildbit/laravel-postmark-provider": "^3.0",
        "wildbit/postmark-php": "^2.5",
        "vanderlee/swaggergen": "^2.3.19"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~5.7"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    }
}

查看更多

提问者
Amit
被浏览
8
Amit 2020-02-07 17:23

匹配我的密码和哈希密码是不一样的。使用过的bcrypt-generator.com生成新的哈希密码并在Db中更新

手动生成哈希密码并在Db中更新它解决了我的问题。

最新帖子

最新文章