我有Laravel 4.2应用程序,并将其更新为Laravel 5.4。为此,我安装了新的Laravel 5.4并迁移了路由,控制器视图等。
除了/ warehouse / login页面之外,我想保护/ warehouse之后的所有页面,例如/ warehouse / dashboard,/ warehouse / accounts等。我已经搜索并使用了这条路线,但无法正常工作。
任何人都可以让我知道什么是正确的身份验证方法。
Route::group(['middleware' => ['auth']], function() {
// uses 'auth' middleware
Route::resource('/warehouse','WarehouseController@index');
});
我的登录名和验证路由为
Route::get('/warehouse/login', array('as' => 'WarehouseAdminLogin', 'uses' => 'WarehouseController@login'));
Route::post('/warehouse/verify', array('as' => 'WarehouseAdminVerify', 'uses' => 'WarehouseController@verify'));
答案 0 :(得分:2)
对于@Entity
@Table(name = "route")
data class Route(
@Column(name = "uid")
@Type(type = "pg-uuid")
@Id
var uid: UUID,
var image: String,
@Column(name = "rate_id")
var rate_id: UUID,
@ManyToMany(cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
@JoinTable(name = "ach",
joinColumns = [JoinColumn(name = "route_id", referencedColumnName = "uid")],
inverseJoinColumns = [JoinColumn(name = "athlete_id", referencedColumnName = "uid")])
var athletes: List<Athlete> = mutableListOf())
@Entity
@Table(name = "athlete")
data class Athlete(
@Column(name = "uid")
@Type(type = "pg-uuid")
@Id
var uid: UUID,
var email: String,
var image: String,
@ManyToMany(mappedBy = "athletes")
var routes: List<Route> = mutableListOf())
,无需在控制器后添加函数名。
所以尝试一下:
Route:resource
对于Route::resource('/warehouse','WarehouseController');
中间件,您可以执行以下操作:
Auth
很明显,登录路由不应位于Route::middleware(['auth']->group(function() {
// Auth routes
});
中间件中!
新来宾用户如何查看登录页面?
在auth
中间件外部使用Auth路由:
auth