嗨,我在laravel的身份验证方面遇到了一些问题。我必须使用两个中间件1。是web和2。auth。我正在使用web中间件,以便可以使用会话来显示flash消息。并希望使用auth中间件对用户/管理员进行身份验证。但我面临一些问题。
下面是我检查授权和重定向到各自路线的功能
public function postLoginForm(){
$email=Input::get('email');
$password=Input::get('password');
$data=[
'email'=>$email,
'password'=>$password
];
$rules=[
'email'=>'required',
'password'=>'required'
];
$validator=Validator::make($data,$rules);
if($validator->fails()){
Session::flash('fail', 'Oops Something went wrong!!');
return redirect()->back()->withErrors($validator);
}
else{
if(Auth::attempt($data)){
$checkStatus=User::select('*')->where('email',$email)->first();
Session::put('email',$checkStatus->email);
Session::put('user_type',$checkStatus->user_type);
if($checkStatus['user_type']=='4'){
if($checkStatus['status']=='0'){
Session::flash('wait', 'Registration is not approved!!');
return "student";
return redirect()->back();
}
else{
return "student else";
return Redirect::route('get.student.dashBoard');
}
}
else if($checkStatus['user_type']=='1'){
return Redirect::route('get.admin.dashBoard');
}
else if($checkStatus['user_type']=='2'){
return 'admin sir view';
return Redirect::route('get.admin.dashBoard');
}
else if($checkStatus['user_type']=='3'){
return 'admin other view';
return Redirect::route('get.admin.dashBoard');
}
else{
Session::flash('fail', 'Oops Something went wrong!!');
return redirect()->back();
}
}
else{
Session::flash('fail', 'Login details not matched!!');
return redirect()->back();
}
}
return 'nothing works';
}
下面是我的管理路线
Route::group(['middleware' => ['web']], function () {
Route::get('/login',
['as' => 'get.login.page',
'uses' => 'LoginController@getLoginPage']);
Route::post('/login-done',
['as' => 'post.login.page',
'uses' => 'LoginController@postLoginForm']);
Route::get('/register',
['as' => 'get.register.page',
'uses' => 'LoginController@getRegisterPage']);
Route::post('/register',
['as' => 'post.register.form',
'uses' => 'LoginController@postRegisterForm']);
Route::get('/forgot-password',
['as' => 'get.forgotPassword.form',
'uses' => 'LoginController@getForgotPasswordForm']);
Route::group(['middleware' => ['auth']], function () {
Route::get('/admin-dashboard',
['as' => 'get.admin.dashBoard',
'uses' => 'admin\PageController@getAdminDashboard']);
Route::get('/all-achievements',
['as' => 'get.achievements',
'uses' => 'admin\AchievementsController@getAchievementsList']);
Route::get('/new-achievement',
['as' => 'get.add.achievement',
'uses' => 'admin\AchievementsController@getAddAchievement']);
Route::post('/add-achievement',
['as' => 'post.achievementsForm',
'uses' => 'admin\AchievementsController@postAchievements']);
Route::get('remove-achievement/{achie_slug}',
['as' => 'post.delete.achievements',
'uses' => 'admin\AchievementsController@postDeleteAchievement']);
Route::get('edit-achievement/{achie_slug}',
['as' => 'get.edit.achievements',
'uses' => 'admin\AchievementsController@getEditAchievement']);
Route::post('update-achievement/{ach_id}',
['as' => 'post.edited.achievement',
'uses' => 'admin\AchievementsController@postEditedAchievement']);
Route::get('/all-news',
['as' => 'get.news.list',
'uses' => 'admin\NewsController@getNewsList']);
Route::get('/add-news',
['as' => 'get.add.news',
'uses' => 'admin\NewsController@getAddNews']);
Route::post('/add-news',
['as' => 'post.add.news',
'uses' => 'admin\NewsController@postAddNews']);
Route::get('/delete-news/{news_slug}',
['as' => 'get.delete.news',
'uses' => 'admin\NewsController@postDeleteNews']);
Route::get('/edit-news/{news_slug}',
['as' => 'get.edit.news',
'uses' => 'admin\NewsController@getEditNews']);
Route::post('/edit-news/{news_slug}',
['as' => 'post.edited.news',
'uses' => 'admin\NewsController@postEditedNews']);
Route::get('/all-admins',
['as' => 'get.admin.list',
'uses' => 'admin\AdminController@getAllAdminList']);
Route::get('/add-admin',
['as' => 'add.new.admin',
'uses' => 'admin\AdminController@getAddNewAdmin']);
Route::post('/add-new-admin',
['as' => 'post.add.new.admin',
'uses' => 'admin\AdminController@postAddNewAdmin']);
Route::get('/all-schedule',
['as' => 'get.timeTable.list',
'uses' => 'admin\TimeTableController@getTimeTableList']);
Route::get('/add-schedule/{id}',
['as' => 'add.timeTable',
'uses' => 'admin\TimeTableController@getAddNewBatch']);
Route::post('/add-new-batch',
['as' => 'add.newBatch',
'uses' => 'admin\TimeTableController@postAddNewBatch']);
Route::post('/save-year-batch',
['as' => 'save.year.batch',
'uses' => 'admin\TimeTableController@postSaveYearBatch']);
Route::get('/schedule-table/{year}',
['as' => 'view.schedule.table',
'uses' => 'admin\TimeTableController@getScheduleTable']);
Route::get('/delete-schedule/{slug}',
['as' => 'delete.schedule.one',
'uses' => 'admin\TimeTableController@postDeleteOneSchedule']);
Route::get('/edit-schedule/{slug}',
['as' => 'edit.schedule.one',
'uses' => 'admin\TimeTableController@getEditScheduleForm']);
Route::post('/save-edited-schedule/{id}',
['as' => 'save.edited.schedule',
'uses' => 'admin\TimeTableController@postEditScheduleForm']);
Route::get('/all-results',
['as' => 'get.all.results',
'uses' => 'admin\ResultsController@getAllResults']);
Route::get('/add-result',
['as' => 'get.add.results',
'uses' => 'admin\ResultsController@getAddResult']);
Route::post('/add-new-result',
['as' => 'post.add.result',
'uses' => 'admin\ResultsController@postAddResult']);
Route::get('/delete-result/{id}',
['as' => 'get.delete.student.result',
'uses' => 'admin\ResultsController@getDeleteResult']);
Route::get('/edit-result/{id}',
['as' => 'get.edit.student.result',
'uses' => 'admin\ResultsController@getEditResult']);
Route::post('/save-edited-result/{id}',
['as' => 'post.edited.result',
'uses' => 'admin\ResultsController@postEditedResult']);
Route::get('/contact-messages',
['as' => 'get.contact.message',
'uses' => 'admin\ContactMessageController@getAllContactMessages']);
Route::get('/contact-messages/{id}',
['as' => 'get.delete.contact.message',
'uses' => 'admin\ContactMessageController@getDeleteContactMessages']);
});
});
每次我试图登录它重定向我到相同的登录页面。
您应该从中间件组中删除web
中间件,以使其正常工作。它适用于web中的所有路由。php
(5.3)和路由。php(5.2.27及更高版本)自动运行,如果手动添加,将中断会话相关功能。
我正在尝试在我的Jenkins工具中配置LDAP身份验证。我已经在Jenkins上完成了以下LDAP身份验证的设置,但我仍然无法登录。 服务器:ldaps://rootdc1.myweb.com:636 根DN:dc=myweb,dc=com 提前感谢!
问题内容: 我正在尝试在python中使用基本身份验证 响应表单 auth 变量: 但是,当我尝试从其他位置获取数据时-我收到401错误 据我了解-在第二个请求中不是替换的会话参数。 问题答案: 您需要使用会话对象,并向 每个请求 发送身份验证。该会话还将为您跟踪Cookie:
我在谷歌的研究中列出了一篇2013年的帖子,其中说这个问题是因为Spring Security LDAP和Java8之间的不兼容。同一篇文章说,它已经在一些Spring引导版本中得到修复。它没有谈到任何非Spring Boot库的修复。 有人尝试过使用Java8进行Spring Security LDAP身份验证吗?请帮忙。
我想构建一个API路由,经过身份验证的用户和未经身份验证的用户都可以调用该路由,并根据用户是否经过身份验证返回数据。 我卡在使用身份验证::检查()。 控制器的功能是这样的: 我最后有两个场景: 情景1 在这种情况下,在控制器中,当我检查Auth::check()在if条件内时,无论用户是否经过身份验证,我总是得到错误条件。 方案 2 在这种情况下,在控制器中,当我检查Auth::check()时
null 这在2.0中可以使用,但如果令牌无效(上面的步骤2)并且声明从未添加,我会得到“no authenticationScheme was specified,and there was no DefaultChallengeScheme found”。 所以现在我读到了2.0版本中身份验证的改变: https://docs.microsoft.com/en-us/aspnet/core/m
问题内容: 我正在上。基本身份验证将于 8月16日起过期。因此我们必须使用Twitter身份验证。但其实施有些复杂。切断了两个步骤。但是问题是我曾经 进行过身份验证,而且文档也很糟糕。我想使用1.6本身的XAuth。建议使用哪个软件包。以及(如果有)或特定于Android以使用身份验证。 问题答案: 编辑:在我的代码中,我这样做: 然后,您必须从以下位置保存令牌和令牌机密 当您想使用令牌时,只需执