【发布时间】:2014-10-24 14:49:07
【问题描述】:
我有一个使用 Laravel 4.2 构建的网站和一个只有登录用户才能访问的控制器:
Route::group(['prefix' => 'pannello-utente', 'before' => 'auth'], function ()
{
Route::get('elenco-animali/{nome?}', ['uses' => 'PazientiController@index']);
Route::get('download/{cartella}/{file}', ['uses' => 'PazientiController@download']);
});
auth 方法要求用户输入电子邮件和密码。
在PazientiController 中,我有__construct 方法,它执行一些检索代码并在其他方法中使用它的查询:
public function __construct()
{
$this->current_user = Auth::user();
//Recupero il codice cliente salvato nel profilo utente
$this->codice = User::find($this->current_user->id)->first()->profile->codice_cliente;
}
此代码仅保存在数据库中,目前没有其他应用程序拥有它,因此我需要每次都执行该查询。
我需要,现在通过curl然后通过智能手机应用程序,用户可以访问该方法,所以我需要用户之前登录:
curl --user chri788@gmail.com:adminadmin localhost:8888/*****/public/pannello-utente/elenco-animali
但我明白了:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="1;url=http://localhost:8888/*****/public/login" />
<title>Redirecting to http://localhost:8888/*****/public/login</title>
</head>
<body>
Redirecting to <a href="http://localhost:8888/******/public/login">http://localhost:8888/****/public/login</a>.
</body>
</html>
如何访问该控制器?
【问题讨论】: