HEPTACOM / HeptacomShopwarePlatformAdminOpenAuth

Shopware plugin to allow open auth logins in the administration
https://www.heptacom.de/
Apache License 2.0
30 stars 10 forks source link

[Bug]: #6

Closed ckupferschmid closed 9 months ago

ckupferschmid commented 1 year ago

Plugin Version

4.2.1

PHP Version

7.4.33

Shopware Version

6.4.17.2

Installation method

Community-Store

Identity provider

Microsoft Azure OIDC

What happened?

Configured Plugin to assign other role than 'Administrator'. The error below is displayed at first login, and the account gets created with 'Administrator' role.

{"errors":[{"code":"0","status":"500","title":"Internal Server Error","detail":"An exception occurred while executing \u0027UPDATE user SET first_name = ?, last_name = ?, email = ?, admin = ?, updated_at = ? WHERE id = ?\u0027 with params [\u0022Chxxx\u0022, \u0022Kxxx\u0022, \u0022chxxx.kxxx@xxxxx.com\u0022, false, \u00222022-12-08 13:51:40.711\u0022, \u0022\xfe\x9a\x4e\xee\x25\x99\x45\x60\x83\x5a\x92\x80\x92\x49\xdd\xb5\u0022]:\n\nSQLSTATE[HY000]: General error: 1366 Incorrect integer value: \u0027\u0027 for column \u0027admin\u0027 at row 1"}]}

Relevant log output

[2022-12-08T13:51:40.713133+00:00] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occurred while executing 'UPDATE user SET first_name = ?, last_name = ?, email = ?, admin = ?, updated_at                                                                                                                                                                                               = ? WHERE id = ?' with params ["Chxxx", "Kxxx", "chxxx.kxxx@xxxxx.com", false, "2022-12-08 13:51:40.711", "\xfe\x9a\x4e\xee\x25\x99\x45\x60\x83\x5a\x92\x80\x92\x49\xdd\xb5"]:  SQLSTATE[HY000]: General error: 1366                                                                                                                                                                                               Incorrect integer value: '' for column 'admin' at row 1" at /opt/shopware/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 128 {"exception":"[object] (Doctrine\\DBAL\\Exception\\DriverException(code: 0): An exc                                                                                                                                                                                              eption occurred while executing 'UPDATE user SET first_name = ?, last_name = ?, email = ?, admin = ?, updated_at = ? WHERE id = ?' with params [\"Chxxx\", \"Kxxx\", \"chxxx.kxxx@xxxxx.com\", false, \"2022-12-08 1                                                                                                                                                                                              3:51:40.711\", \"\\xfe\\x9a\\x4e\\xee\\x25\\x99\\x45\\x60\\x83\\x5a\\x92\\x80\\x92\\x49\\xdd\\xb5\"]:\n\nSQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'admin' at row 1 at /opt/shopware/vendor/doctrine/dbal/l                                                                                                                                                                                              ib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:128)\n[previous exception] [object] (Doctrine\\DBAL\\Driver\\PDO\\Exception(code: HY000): SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'admin' at row 1 at /op                                                                                                                                                                                              t/shopware/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18)\n[previous exception] [object] (PDOException(code: HY000): SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'admin' at row 1 at /op                                                                                                                                                                                              t/shopware/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117)"} []
silviokennecke commented 1 year ago

Hi Christian,

I just tried to reproduce your problem. Apparently I could not reproduce it with the information you provided.

Could you send me the following information via mail?

AndreasA commented 1 year ago

Hi @silviokennecke The problem occurs if one sets that new users should be created as non admins due to t his line: https://github.com/HEPTACOM/HeptacomShopwarePlatformAdminOpenAuth/blob/4.2.1/src/Service/UserResolver.php#L216

You run a DBAL update but do not provide the necessary types, therefore e.g. the boolean value for admin is provided as bool instead of integer. You can either manually convert it or just provided the necessary types array e.g. ['admin' => Types::BOOLEAN].

AndreasA commented 1 year ago

This PR should fix it - at least it fixed the issue I explained above: https://github.com/HEPTACOM/HeptacomShopwarePlatformAdminOpenAuth/pull/8

ckupferschmid commented 1 year ago

I have tested the fix provided by @AndreasA and it works from what I can tell. I have a newly setup system using php 8.1 and shopware 6.4.20.2 and the issue was still the same. Manually installed the fix and it is working now. Would help, if this could be released as bug fix.

JoshuaBehrens commented 1 year ago

I picked it up for you as a new 4.3 release of this plugin :) the latest code is already on master.

Please try out 4.3.0-beta.1

silviokennecke commented 9 months ago

I'll close this issue due to inactivity for now.