Project

General

Profile

Bug #34915

External users cannot update user attributes on login

Added by Adam Winberg 3 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

When a user logins Foreman tries to update user attributes (firstname, surname, email) if needed. This does not work for external users - login works but attributes remain unchanged.

I'm guessing this is some permission issue, sql debugging shows

2022-05-12T10:36:05 [D|sql|5ba6dffa]    (0.6ms)  SELECT COUNT(*) FROM "permissions" WHERE "permissions"."resource_type" = $1 AND (permissions.name LIKE 'edit_%')  [["resource_type", "User"]]
2022-05-12T10:36:05 [D|sql|5ba6dffa]   Permission Load (0.5ms)  SELECT "permissions".* FROM "permissions" WHERE "permissions"."resource_type" = $1 AND (permissions.name LIKE 'edit_%') ORDER BY "permissions"."id" ASC LIMIT $2  [["resource_type", "User"], ["LIMIT", 1]]
2022-05-12T10:36:05 [D|sql|5ba6dffa]    (0.4ms)  ROLLBACK
2022-05-12T10:36:05 [D|sql|5ba6dffa]   Usergroup Load (1.1ms)  SELECT "usergroups".* FROM "usergroups" INNER JOIN "usergroup_members" ON "usergroups"."id" = "usergroup_members"."usergroup_id" WHERE "usergroup_members"."member_id" = $1 AND "usergroup_members"."member_type" = $2 ORDER BY usergroups.name  [["member_id", 2], ["member_type", "User"]]

If i edit

def self.find_or_create_external_user(attrs, auth_source_name)
in
app/models/user.rb
and run the update as anonomous_admin instead it works:
        User.as_anonymous_admin do
          user.update(Hash[attrs.select { |k, v| v.present? }])
        end

Also available in: Atom PDF