尊龙凯时人生就是博

laravelÔõôÐ޸ĵǼÑéÖ¤ÒÔÖª×㶨ÖÆÐèÇó

laravelÊÇÒ»¿îºÜÊÇÊ¢ÐеÄphp¿ò¼Ü £¬ËüÌṩÁËÐí¶à±ã½ÝµÄ¹¦Ð§ÓÃÓÚwebÓ¦ÓóÌÐòµÄ¹¹½¨¡£ÆäÖÐ £¬laravel×Ô´øµÄÓû§ÈÏ֤ϵͳÊÇ¿ª·¢Ö°Ô±ÔÚ¹¹½¨webÓ¦ÓóÌÐòʱһÏî·Ç³ £»ù±¾µÄ¹¦Ð§¡£Ä¬ÈÏÇéÐÎÏ £¬laravelµÄÓû§ÈÏ֤ϵͳ»áÔÚÓû§µÇ¼ʱ¾ÙÐÐÉí·ÝÑéÖ¤ £¬¿ÉÊÇÓÐʱ¼äÎÒÃÇÐèÒª¶ÔÆä¾ÙÐÐÐÞ¸ÄÒÔÖª×ãÎÒÃǵÄÐèÇó¡£

ÔÚ±¾ÎÄÖÐ £¬ÎÒÃǽ«ÏÈÈÝÔõÑùÐÞ¸ÄLaravelÓû§µÇ¼ÑéÖ¤ÒÔÖª×㶨ÖÆÐèÇó¡£ÎÒÃǽ«Îª¶ÁÕßÌṩÁ½ÖÖ³£¼ûµÄ³¡¾°²¢ÌÖÂÛÔõÑù½â¾öÕâЩÇéÐΣº

Ï£ÍûÔÚÓû§µÇ¼ʱÌí¼ÓÌØÁíÍâÑéÖ¤Ìõ¼þ £»

Ï£ÍûÑéÖ¤µÇ¼ºóÃÜÂëÊÇ·ñÓâÆÚ £¬ÈôÊÇÓâÆÚÔòÐèÒªÓû§¾ÙÐÐÃÜÂëÖØÖá£

Ò»¡¢Ìí¼ÓÌØÁíÍâÑéÖ¤Ìõ¼þ

ÔÚLaravelµÄĬÈÏÓû§ÈÏ֤ϵͳÖÐ £¬Óû§Ö»ÐèÒªÌṩ׼ȷµÄÓÊÏäºÍÃÜÂë¼´¿ÉÍê³ÉµÇ¼¡£¿ÉÊÇÓÐʱ¼ä £¬ÎÒÃÇÐèÒªÓû§ÌṩÌØÁíÍâÐÅÏ¢ÒÔ¾ÙÐÐÕë¶ÔÐÔµÄÑéÖ¤¡£

ºÃ±È £¬ÎÒÃÇÐèÒªÓû§Ìṩһ¸öÇå¾²ÎÊÌâµÄÃÕµ× £¬ÒÔÈ·±£Óû§²¢·Ç»úеÈË¡£¾ÙÐÐÕâÖÖÆ¥Åä¿ÉÒÔ´ÓÊý¾Ý¿âÖлñÈ¡Óû§´æ´¢µÄÇå¾²ÎÊÌâºÍÃÕµ× £¬È»ºóÓëÓû§ÌṩµÄÐÅÏ¢¾ÙÐбȶÔ¡£ÏÂÃæÊÇÔõÑùʵÏÖÕâÖÖÑéÖ¤£º

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÔÚLoginControllerÖÐ £¬ÖØдloginÒªÁìÒÔÑéÖ¤Çå¾²ÎÊÌâÃյס£¿ÉÒÔÕâÑùд£º

public function login(Request $request)
{
    $answer = $request->input('answer');
    $user = User::where('email', $request->email)->first();
  
    if (!$user) {
        return redirect()->route('login')
            ->withInput($request->only('email', 'remember'))
            ->withErrors([
                'email' => 'The provided credentials are incorrect.',
            ]);
    }

    if ($user->isRobot() || $user->answer !== $answer) {
        return redirect()->route('login')
            ->withInput($request->only('email', 'remember'))
            ->withErrors([
                'email' => 'The provided credentials are incorrect.',
            ]);
    }

    if (Auth::attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
        return redirect()->intended('/dashboard');
    }

    return redirect()->route('login')
        ->withInput($request->only('email', 'remember'))
        ->withErrors([
            'email' => 'The provided credentials are incorrect.',
        ]);
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖÐ £¬ÎÒÃÇÊ×ÏÈ»ñÈ¡Óû§ÌṩµÄÃÕµ× £¬È»ºó´ÓÊý¾Ý¿âÖвéÕÒÓû§¡£ÈôÊÇÓû§²»±£´æ £¬ÎÒÃÇÁ¬Ã¦Ìøת»ØµÇ¼ҳÃæ²¢¸æËßÓû§ÌṩµÄƾ֤²»×¼È·¡£

ÈôÊÇÓû§±»±ê¼ÇΪ»úеÈË £¬»òÕßÌṩµÄÃÕµ×ÓëÊý¾Ý¿âÖÐ×ֶβ»Æ¥Åä £¬ÎÒÃÇͬÑù½«Óû§Öض¨Ïò»ØµÇ¼ҳÃæ¡£

¿ÉÊÇ £¬ÈôÊÇÓû§Í¨¹ýÁËÇå¾²ÎÊÌâµÄÑéÖ¤ £¬ÎÒÃǽ«Å²ÓÃAuth::attempt()ÒªÁìʵÑéµÇÈÎÃü»§¡£ÈôÊǵǼÀÖ³É £¬ÎÒÃǽ«Öض¨ÏòÓû§µ½ËûÃÇ×î³õÇëÇóµÄÒ³Ãæ¡£

¶þ¡¢ÃÜÂëÓâÆÚÑéÖ¤

ÈôÊÇÄúµÄÓ¦ÓóÌÐòÐèÒªÃÜÂëÓâÆÚ¼ì²é¹¦Ð§ £¬ÄÇôÎÒÃÇ¿ÉÒÔʹÓÃLaravelµÄAuthÄ£¿é £¬¼ì²éÓû§ÃÜÂëÓâÆÚʱ¼ä´Á¡£ÈôÊÇʱ¼ä´ÁÅú×¢ÃÜÂëÒѾ­ÓâÆÚ £¬ÎÒÃÇ¿ÉÒÔÒªÇóÓû§ÖØÖÃËûÃǵÄÃÜÂë¡£

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÔÚUserÄ£×ÓÖÐÌí¼ÓÒ»¸öÃÜÂëÓâÆÚʱ¼ä´Á×ֶΣº

protected $dates = ['password_updated_at'];

µÇ¼ºó¸´ÖÆ

È»ºó £¬ÎÒÃÇÐèÒªÖØдAuthenticatable½Ó¿ÚÖеÄhasPasswordExpired()ÒªÁ죺

public function hasPasswordExpired()
{
    $expirationDate = Carbon::now()->subDays(config('auth.password_expiration_days'));
    return $this->password_updated_at->lt($expirationDate);
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖÐ £¬ÎÒÃÇÊ×ÏÈ»ñÈ¡Ä¿½ñʱ¼äºÍÃÜÂëÓâÆÚʱ¼ä¾àÀëÇ°µÄÈÕÆÚ £¬²¢½«Æä·ÅÈëÏÞÆÚ±äÁ¿ÖС£È»ºó £¬ÎÒÃǽÏÁ¿ÃÜÂë¸üÐÂʱ¼ä´ÁºÍÓâÆÚÈÕÆÚ¡£ÈôÊÇÃÜÂëÓâÆÚʱ¼ä´ÁÔçÓÚÏÞÆÚÈÕÆÚ £¬ÄÇô˵Ã÷ÃÜÂëÒѾ­ÓâÆÚ¡£

½ÓÏÂÀ´ £¬ÎÒÃÇÐèÒª¸üÐÂLoginControllerÖеÄlogin()ÒªÁìÒÔÆôÓÃÃÜÂëÓâÆÚ¼ì²â¡£Îª´Ë £¬ÎÒÃÇÐèÒªÌí¼ÓÒÔÏ´úÂëƬ¶Ï£º

public function login(Request $request)
{
    $credentials = $request->only('email', 'password');

    if (Auth::attempt($credentials)) {
        if (Auth::user()->hasPasswordExpired()) {
            Auth::logout();
            return redirect('login')->withErrors(['password' => 'Your password has expired. Please reset it.']);
        }

        return redirect()->intended('/dashboard');
    }

    return redirect('login')->withErrors(['email' => 'Your email or password is incorrect.']);
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖÐ £¬ÈôÊÇÓû§µÇ¼ºóÃÜÂëÓâÆÚ £¬ÎÒÃǽ«·µ»ØÒ»¸ö°üÀ¨¹ýʧÐÂÎŵÄÖض¨ÏòÏìÓ¦¡£Óû§½«±»ÆȾÙÐÐÃÜÂëÖØÖÃÒÔ¼ÌÐøʹÓÃÓ¦ÓóÌÐò¡£

×ܽ᣺

ÒÔÉÏÊÇÁ½ÖÖ³£¼ûµÄÇéÐÎÏ £¬ÐÞ¸ÄLaravelÓû§µÇ¼ÑéÖ¤µÄ½â¾ö¼Æ»®¡£µÚÒ»ÖÖÇéÐÎÊÇÔÚÓû§µÇ¼ʱÌí¼ÓÁËÌØÁíÍâÑéÖ¤Ìõ¼þ £¬ÎÒÃÇʹÓÃÁËÒ»¸öÇå¾²ÎÊÌâÀ´ÑéÖ¤Óû§ÊÇ·ñΪһСÎÒ˽ÈËÀà¡£µÚ¶þÖÖÇéÐÎÊÇÏ£ÍûÑéÖ¤µÇ¼ºóÃÜÂëÊÇ·ñÓâÆÚ £¬ÈôÊÇÓâÆÚÔòÐèÒªÓû§¾ÙÐÐÃÜÂëÖØÖá£

LaravelµÄĬÈÏÈÏ֤ϵͳºÜÊÇÇ¿Ê¢ £¬Ëü°üÀ¨Ðí¶à¹¦Ð§ºÍÑ¡ÏîÓÃÓÚÖª×ã²î±ðÀàÐ͵ÄÓ¦ÓóÌÐòÐèÇó¡£Í¨¹ý¶ÔÆä¾ÙÐÐÐ޸ĺÍÀ©Õ¹ £¬ÎÒÃÇ¿ÉÒÔʹÆäÖª×ãÎÒÃÇÌض¨µÄÐèÇó¡£

ÒÔÉϾÍÊÇlaravelÔõôÐ޸ĵǼÑéÖ¤ÒÔÖª×㶨ÖÆÐèÇóµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ