session log as
This commit is contained in:
parent
dea56f3c8c
commit
a91807ba12
@ -2,6 +2,8 @@
|
||||
|
||||
use App\User;
|
||||
use Input;
|
||||
use Auth;
|
||||
use Session;
|
||||
|
||||
class AdminController extends Controller {
|
||||
|
||||
@ -82,4 +84,25 @@ class AdminController extends Controller {
|
||||
return redirect('/admin')->with('message_delete', 'User supprimé avec succès');
|
||||
}
|
||||
|
||||
/**
|
||||
* Log as one user
|
||||
*
|
||||
*/
|
||||
public function logAs()
|
||||
{
|
||||
// Saving idUser in Session
|
||||
$me = Auth::user()->id;
|
||||
Session::put('admin', $me);
|
||||
|
||||
// logout from Auth
|
||||
Auth::logout();
|
||||
|
||||
// Log as referent
|
||||
$idUser = Input::get('idUser');
|
||||
Auth::loginUsingId($idUser);
|
||||
|
||||
// Redirect referent route
|
||||
return redirect('/referent');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,4 +36,5 @@ Route::group(['middleware' => 'admin'], function ()
|
||||
Route::post('addUser', 'AdminController@addUser');
|
||||
Route::post('deleteUser', 'AdminController@deleteUser');
|
||||
Route::post('updateUser', 'AdminController@updateUser');
|
||||
Route::post('logAs', 'AdminController@logAs');
|
||||
});
|
@ -25,9 +25,6 @@
|
||||
<tbody>
|
||||
@foreach ($users as $user)
|
||||
@if ($user->droits != 2 && $user != $me || ($user->droits != 0 && $me->droits == 2 && $user != $me))
|
||||
<form method="POST" role="form" action="deleteUser">
|
||||
<input type="hidden" name="idUser" value="{{ $user->id }}">
|
||||
<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
|
||||
<tr style="background-color: #F6E3CE">
|
||||
<td>{{$user->firstname}}</td>
|
||||
<td>{{$user->lastname}}</td>
|
||||
@ -40,12 +37,20 @@
|
||||
@endif
|
||||
<td>
|
||||
@if ($user->droits == 0)
|
||||
<a href="#" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-log-in"></span></a>
|
||||
<form method="POST" role="form" action="logAs">
|
||||
<input type="hidden" name="idUser" value="{{ $user->id }}">
|
||||
<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
|
||||
<button type="submit" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-log-in"></span></a>
|
||||
</form>
|
||||
@endif
|
||||
<button type="submit" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
<form method="POST" role="form" action="deleteUser">
|
||||
<input type="hidden" name="idUser" value="{{ $user->id }}">
|
||||
<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
|
||||
<button type="submit" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
|
||||
@endif
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
Reference in New Issue
Block a user