Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
L
ldap-auth
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
German Shvetsov
ldap-auth
Commits
ca31e7cb
Commit
ca31e7cb
authored
Apr 01, 2016
by
Stan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated EXAMPLE.MD
Removing the Dependency Injection which is not needed for Laravel 5.2
parent
fcf9cc47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
40 deletions
+16
-40
EXAMPLE.md
EXAMPLE.md
+16
-40
No files found.
EXAMPLE.md
View file @
ca31e7cb
# 1. Create an AuthController
Create your Authentication Controller manually or use
`php artisan make:controller AuthController`
`php artisan make:controller
Ldap
AuthController`
```php
...
...
@@ -9,44 +9,18 @@ Create your Authentication Controller manually or use
namespace App\Http\Controllers;
use App\Http\Requests\LoginRequest;
use Illuminate\Contracts\Auth\Guard;
use Krenor\LdapAuth\Objects\LdapUser;
use Illuminate\Http\Request;
use App\Http\Requests;
class AuthController extends Controller
{
/**
* the model instance
*
* @var User
*/
protected $user;
/**
* The Guard implementation.
*
* @var Authenticator
*/
protected $auth;
/**
* Create a new authentication controller instance.
*
* @param Authenticator|Guard $auth
* @param LdapUser $user
*/
public function __construct(Guard $auth, LdapUser $user)
{
$this->auth = $auth;
$this->user = $user;
}
/**
* Show the application login form.
*
* @return Response
*/
public function getLogin()
public function getLogin
Form
()
{
return view('login');
}
...
...
@@ -54,13 +28,19 @@ class AuthController extends Controller
/**
* Handle a login request to the application.
*
* @param
Login
Request $request
* @param Request $request
*
* @return Response
*/
public function
postLogin(Login
Request $request)
public function
login(
Request $request)
{
if ( $this->auth->attempt( $request->only('username', 'password') ) ) {
// Validate credentials
$this->validate($request, [
'username' => 'required',
'password' => 'required',
]);
if ( auth()->attempt( $request->only('username', 'password') ) ) {
// Redirect to indented page or fall back to index page
return redirect()->intended('/');
}
...
...
@@ -77,7 +57,7 @@ class AuthController extends Controller
*/
public function getLogout()
{
$this->auth
->logout();
auth()
->logout();
return redirect('/');
}
...
...
@@ -85,9 +65,6 @@ class AuthController extends Controller
```
You can create your own request rules as mine basically
use
`required`
on both username and password.
# 2. Configure the routes
Note: It is important to place these views in the 'web' middleware!
...
...
@@ -118,4 +95,4 @@ You're set to go! Now create some Views and try it out. :)
As I don't like the default path for a login to be
`/auth/login`
feel free to change
this file at line 41 :
`ROOT/app/Http/Middleware/Authenticate.php`
`return redirect()->guest('/login');`
\ No newline at end of file
`return redirect()->guest('/login');`
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment