@@ -43,46 +43,46 @@ public function __construct(Guard $auth)
43
43
public function handle (Request $ request , Closure $ next )
44
44
{
45
45
// If the user is already logged in, no need to reauthenticate
46
- if ( ! $ this ->auth ->check () ) {
47
-
46
+ if (! $ this ->auth ->check ()) {
47
+
48
48
// Retrieve the SSO login attribute.
49
49
$ auth = $ this ->getWindowsAuthAttribute ();
50
-
50
+
51
51
// Retrieve the SSO input key.
52
52
$ key = key ($ auth );
53
-
53
+
54
54
// Handle Windows Authentication.
55
55
if ($ account = $ request ->server ($ auth [$ key ])) {
56
56
// Usernames may be prefixed with their domain,
57
57
// we just need their account name.
58
58
$ username = explode ('\\' , $ account );
59
-
59
+
60
60
if (count ($ username ) === 2 ) {
61
61
list ($ domain , $ username ) = $ username ;
62
62
} else {
63
63
$ username = $ username [key ($ username )];
64
64
}
65
-
65
+
66
66
// Create a new user LDAP user query.
67
67
$ query = $ this ->newAdldapUserQuery ();
68
-
68
+
69
69
// Filter the query by the username attribute
70
70
$ query ->whereEquals ($ key , $ username );
71
-
71
+
72
72
// Retrieve the first user result
73
73
$ user = $ query ->first ();
74
-
74
+
75
75
if ($ user instanceof User) {
76
76
$ model = $ this ->getModelFromAdldap ($ user , str_random ());
77
-
77
+
78
78
if ($ model instanceof Model && $ this ->auth ->guest ()) {
79
79
// Double check user instance before logging them in.
80
80
$ this ->auth ->login ($ model );
81
81
}
82
82
}
83
83
}
84
84
}
85
-
85
+
86
86
return $ this ->returnNextRequest ($ request , $ next );
87
87
}
88
88
0 commit comments