如何解密密码以登录laravel?

更改密码时,我正在使用此功能


public function passwordChange(Request $request, $userId)

    {

        $user = User::find($userId);

        $user->password = Crypt::encrypt(Input::get('password'));

        $user->save();

        return redirect('my-profile');

    }

所以在我的 mongoDb 数据库密码以加密形式插入,所以每当我必须登录系统时,我如何将我的密码与数据库密码进行比较


 public function authenticate(Request $request)

    {


        $rules = array(

            'company_email' => 'required|email|exists:users,company_email',

            'password' => 'required|string|max:20|min:4',

        );


        $validator = Validator::make(Input::all(), $rules);

        if ($validator->fails()) 

        {

            return view('pages.login')->with('v_errors', $validator->errors()->messages());

        } 

        else 

        {

            //get email and query

            $authenticateMe = $request->only('company_email', 'password');

            $user = User::where($authenticateMe)->first();


            if (empty($user)) 

            {

                return view('pages.login')->with('not_exists', 'true');

            }

            //session set

            // Session::put('key', $user->username, $user->file);

            Session::put('key', ['username' => $user->username, 'email' => $user->company_email, 'userId' => $user->id, 'profilePicture' => $user->file]);

            return redirect('my-profile');

        }

    }

我没有使用 php artisan make:auth 会有人帮忙吗??


呼唤远方
浏览 223回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP