dongyang2229 2017-02-28 13:18
浏览 12
已采纳

auth ::尝试不能正常工作

My login in laravel isnt working properly. I've been stuck here for a long time now. This is my login controller code

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;


class UsersController extends Controller
{
protected function dashboard(Request $request)
{

    if (Auth::attempt(array('account_number'=>$request['accountnumber-login'], 'password'=> $request['txt-password']))) {
        return redirect()->intended('viewdashboard');
    }

} 

protected function viewdashboard()
{
    return view('dashboard');
}
}

..in this controller the 'account-number' is the account number column in the database and the 'password' is the password column in the database. I've done everything correctly yet it does not redirect me to the dashboard view. Please help

and this is my html form

<html>
<form action="dashboard" method="GET">
<input type="number" name="accountnumber">
<input type="password" name="password">
</form

</html>

this is my web route folder

Route::get('dashboard', function(){
return view('dashboard_view');
}

pls help, please.

  • 写回答

2条回答 默认 最新

  • dongmou5628 2017-02-28 13:29
    关注

    You're not using the UsersController in the route.

    Route::get('dashboard', 'App\Http\Controllers\UsersController@dashboard');
    

    Also you are accessing request data the wrong way.

    Use

    $request->input('accountnumber');
    

    EDIT:

    And thirdly the dashboard method must be public

     public function dashboard(Request $request) 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序