Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
db50dc5b
Commit
db50dc5b
authored
12 years ago
by
Chris Leppanen
Browse files
Options
Downloads
Patches
Plain Diff
Issue #1567508 by kruser, beansboxchrispang: Fixed User import is incorrectly changing passwords.
parent
7bac6180
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/FeedsUserProcessor.inc
+13
-2
13 additions, 2 deletions
plugins/FeedsUserProcessor.inc
tests/feeds_processor_user.test
+31
-4
31 additions, 4 deletions
tests/feeds_processor_user.test
with
44 additions
and
6 deletions
plugins/FeedsUserProcessor.inc
+
13
−
2
View file @
db50dc5b
...
@@ -40,7 +40,10 @@ class FeedsUserProcessor extends FeedsProcessor {
...
@@ -40,7 +40,10 @@ class FeedsUserProcessor extends FeedsProcessor {
* Loads an existing user.
* Loads an existing user.
*/
*/
protected
function
entityLoad
(
FeedsSource
$source
,
$uid
)
{
protected
function
entityLoad
(
FeedsSource
$source
,
$uid
)
{
return
user_load
(
$uid
);
// Copy the password so that we can compare it again at save.
$user
=
user_load
(
$uid
);
$user
->
feeds_original_pass
=
$user
->
pass
;
return
$user
;
}
}
/**
/**
...
@@ -59,7 +62,15 @@ class FeedsUserProcessor extends FeedsProcessor {
...
@@ -59,7 +62,15 @@ class FeedsUserProcessor extends FeedsProcessor {
if
(
$this
->
config
[
'defuse_mail'
])
{
if
(
$this
->
config
[
'defuse_mail'
])
{
$account
->
mail
=
$account
->
mail
.
'_test'
;
$account
->
mail
=
$account
->
mail
.
'_test'
;
}
}
user_save
(
$account
,
(
array
)
$account
);
$edit
=
(
array
)
$account
;
// Remove pass from $edit if the password is unchanged.
if
(
isset
(
$account
->
feeds_original_pass
)
&&
$account
->
pass
==
$account
->
feeds_original_pass
)
{
unset
(
$edit
[
'pass'
]);
}
user_save
(
$account
,
$edit
);
if
(
$account
->
uid
&&
!
empty
(
$account
->
openid
))
{
if
(
$account
->
uid
&&
!
empty
(
$account
->
openid
))
{
$authmap
=
array
(
$authmap
=
array
(
'uid'
=>
$account
->
uid
,
'uid'
=>
$account
->
uid
,
...
...
This diff is collapsed.
Click to expand it.
tests/feeds_processor_user.test
+
31
−
4
View file @
db50dc5b
...
@@ -34,12 +34,12 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase {
...
@@ -34,12 +34,12 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase {
0
=>
array
(
0
=>
array
(
'source'
=>
'name'
,
'source'
=>
'name'
,
'target'
=>
'name'
,
'target'
=>
'name'
,
'unique'
=>
0
,
'unique'
=>
FALSE
,
),
),
1
=>
array
(
1
=>
array
(
'source'
=>
'mail'
,
'source'
=>
'mail'
,
'target'
=>
'mail'
,
'target'
=>
'mail'
,
'unique'
=>
1
,
'unique'
=>
TRUE
,
),
),
2
=>
array
(
2
=>
array
(
'source'
=>
'since'
,
'source'
=>
'since'
,
...
@@ -74,7 +74,7 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase {
...
@@ -74,7 +74,7 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase {
$this
->
assertText
(
'Created 3 users'
);
$this
->
assertText
(
'Created 3 users'
);
// 1 user has an invalid email address, all users should be assigned
// 1 user has an invalid email address, all users should be assigned
// the manager role.
// the manager role.
$this
->
assertText
(
'Failed importing 2 user'
);
$this
->
assertText
(
'Failed importing 2 user
s.
'
);
$this
->
drupalGet
(
'admin/people'
);
$this
->
drupalGet
(
'admin/people'
);
$this
->
assertText
(
'Morticia'
);
$this
->
assertText
(
'Morticia'
);
$this
->
assertText
(
'Fester'
);
$this
->
assertText
(
'Fester'
);
...
@@ -84,12 +84,39 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase {
...
@@ -84,12 +84,39 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase {
$count
=
db_query
(
"SELECT count(*) FROM
{
users_roles
}
WHERE rid = :rid"
,
array
(
':rid'
=>
$admin_rid
))
->
fetchField
();
$count
=
db_query
(
"SELECT count(*) FROM
{
users_roles
}
WHERE rid = :rid"
,
array
(
':rid'
=>
$admin_rid
))
->
fetchField
();
$this
->
assertEqual
(
$count
,
0
,
t
(
'No imported user was assigned the administrator role.'
));
$this
->
assertEqual
(
$count
,
0
,
t
(
'No imported user was assigned the administrator role.'
));
// @todo Test status setting, update existing and role settings.
// Run import again, verify no new users.
$this
->
importFile
(
'user_import'
,
$this
->
absolutePath
()
.
'/tests/feeds/users.csv'
);
$this
->
assertText
(
'Failed importing 2 users.'
);
// Attempt to log in as one of the imported users.
// Attempt to log in as one of the imported users.
$account
=
user_load_by_name
(
'Morticia'
);
$account
=
user_load_by_name
(
'Morticia'
);
$this
->
assertTrue
(
$account
,
'Imported user account loaded.'
);
$this
->
assertTrue
(
$account
,
'Imported user account loaded.'
);
$account
->
pass_raw
=
'mort'
;
$account
->
pass_raw
=
'mort'
;
$this
->
drupalLogin
(
$account
);
$this
->
drupalLogin
(
$account
);
// Login as admin.
$this
->
drupalLogin
(
$this
->
admin_user
);
// Removing a mapping forces updating without needing a different file.
// We are also testing that if we don't map anything to the user's password
// that it will keep its existing one.
$mappings
=
array
(
3
=>
array
(
'source'
=>
'password'
,
'target'
=>
'pass'
,
),
);
$this
->
removeMappings
(
'user_import'
,
$mappings
);
$this
->
setSettings
(
'user_import'
,
'FeedsUserProcessor'
,
array
(
'update_existing'
=>
2
));
$this
->
importFile
(
'user_import'
,
$this
->
absolutePath
()
.
'/tests/feeds/users.csv'
);
// Assert result.
$this
->
assertText
(
'Updated 3 users'
);
$this
->
assertText
(
'Failed importing 2 user'
);
// Attempt to log in as one of the imported users.
$account
=
user_load_by_name
(
'Fester'
);
$this
->
assertTrue
(
$account
,
'Imported user account loaded.'
);
$account
->
pass_raw
=
'fest'
;
$this
->
drupalLogin
(
$account
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment