Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
0b807696
Commit
0b807696
authored
Apr 18, 2014
by
Nathaniel Catchpole
Browse files
Issue
#2241461
by Berdir, juampy: Locale + basic_auth results in current_user circular reference.
parent
1e15efd7
Changes
4
Hide whitespace changes
Inline
Side-by-side
core/modules/basic_auth/lib/Drupal/basic_auth/Authentication/Provider/BasicAuth.php
View file @
0b807696
...
...
@@ -45,11 +45,11 @@ class BasicAuth implements AuthenticationProviderInterface {
protected
$flood
;
/**
* The
user stor
age.
* The
entity man
age
r
.
*
* @var \Drupal\
user\UserStor
ageInterface
* @var \Drupal\
Core\Entity\EntityMan
age
r
Interface
*/
protected
$
userStor
age
;
protected
$
entityMan
age
r
;
/**
* Constructs a HTTP basic authentication provider object.
...
...
@@ -67,7 +67,7 @@ public function __construct(ConfigFactoryInterface $config_factory, UserAuthInte
$this
->
configFactory
=
$config_factory
;
$this
->
userAuth
=
$user_auth
;
$this
->
flood
=
$flood
;
$this
->
userStor
age
=
$entity_manager
->
getStorage
(
'user'
)
;
$this
->
entityMan
age
r
=
$entity_manager
;
}
/**
...
...
@@ -94,7 +94,7 @@ public function authenticate(Request $request) {
// in to many different user accounts. We have a reasonably high limit
// since there may be only one apparent IP for all users at an institution.
if
(
$this
->
flood
->
isAllowed
(
'basic_auth.failed_login_ip'
,
$flood_config
->
get
(
'ip_limit'
),
$flood_config
->
get
(
'ip_window'
)))
{
$accounts
=
$this
->
userStorage
->
loadByProperties
(
array
(
'name'
=>
$username
,
'status'
=>
1
));
$accounts
=
$this
->
entityManager
->
getStorage
(
'user'
)
->
loadByProperties
(
array
(
'name'
=>
$username
,
'status'
=>
1
));
$account
=
reset
(
$accounts
);
if
(
$account
)
{
if
(
$flood_config
->
get
(
'uid_only'
))
{
...
...
@@ -114,7 +114,7 @@ public function authenticate(Request $request) {
$uid
=
$this
->
userAuth
->
authenticate
(
$username
,
$password
);
if
(
$uid
)
{
$this
->
flood
->
clear
(
'basic_auth.failed_login_user'
,
$identifier
);
return
$this
->
userStorage
->
load
(
$uid
);
return
$this
->
entityManager
->
getStorage
(
'user'
)
->
load
(
$uid
);
}
else
{
// Register a per-user failed login event.
...
...
core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationTest.php
View file @
0b807696
...
...
@@ -52,6 +52,10 @@ protected function setUpLanguage() {
public
function
testInstaller
()
{
$this
->
assertUrl
(
'user/1'
);
$this
->
assertResponse
(
200
);
// Ensure that we can enable basic_auth on a non-english site.
$this
->
drupalPostForm
(
'admin/modules'
,
array
(
'modules[Web services][basic_auth][enable]'
=>
TRUE
),
t
(
'Save configuration'
));
$this
->
assertResponse
(
200
);
}
}
core/modules/user/lib/Drupal/user/UserAuth.php
View file @
0b807696
...
...
@@ -17,11 +17,11 @@
class
UserAuth
implements
UserAuthInterface
{
/**
* The
user stor
age.
* The
entity man
age
r
.
*
* @var \Drupal\Core\Entity\Entity
Stor
ageInterface
* @var \Drupal\Core\Entity\Entity
Man
age
r
Interface
*/
protected
$
stor
age
;
protected
$
entityMan
age
r
;
/**
* The password service.
...
...
@@ -39,7 +39,7 @@ class UserAuth implements UserAuthInterface {
* The password service.
*/
public
function
__construct
(
EntityManagerInterface
$entity_manager
,
PasswordInterface
$password_checker
)
{
$this
->
stor
age
=
$entity_manager
->
getStorage
(
'user'
)
;
$this
->
entityMan
age
r
=
$entity_manager
;
$this
->
passwordChecker
=
$password_checker
;
}
...
...
@@ -50,7 +50,7 @@ public function authenticate($username, $password) {
$uid
=
FALSE
;
if
(
!
empty
(
$username
)
&&
!
empty
(
$password
))
{
$account_search
=
$this
->
storage
->
loadByProperties
(
array
(
'name'
=>
$username
));
$account_search
=
$this
->
entityManager
->
getStorage
(
'user'
)
->
loadByProperties
(
array
(
'name'
=>
$username
));
if
(
$account
=
reset
(
$account_search
))
{
if
(
$this
->
passwordChecker
->
check
(
$password
,
$account
))
{
...
...
core/modules/user/tests/Drupal/user/Tests/UserAuthTest.php
View file @
0b807696
...
...
@@ -80,8 +80,7 @@ public function setUp() {
$this
->
userStorage
=
$this
->
getMock
(
'Drupal\Core\Entity\EntityStorageInterface'
);
$entity_manager
=
$this
->
getMock
(
'Drupal\Core\Entity\EntityManagerInterface'
);
// Getting the user storage should only happen once per test.
$entity_manager
->
expects
(
$this
->
once
())
$entity_manager
->
expects
(
$this
->
any
())
->
method
(
'getStorage'
)
->
with
(
'user'
)
->
will
(
$this
->
returnValue
(
$this
->
userStorage
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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