I am using the latest Oauth Plugin as documented in https://docs.osticket.com/en/latest/OAuth2/Microsoft%20Authentication%20(SSO)%20Guide.html
However, upon enabling it some of my existing users ended up with duplicate database entries (a new user account got created instead of using the existing one):
10.244.2.66 - 24/Nov/2022:20:31:26 +0000 "GET " 500
NOTICE: PHP message: PHP Fatal error: Uncaught ObjectNotUnique: One object was expected; however multiple objects in the database matched the query. In fact, there are 2 matching objects. in /var/www/html/include/class.orm.php:1364
Stack trace:
#0 /var/www/html/include/class.orm.php(606): QuerySet->one()
#1 /var/www/html/scp/users.php(23): VerySimpleModel::lookup()
#2 {main}
thrown in /var/www/html/include/class.orm.php on line 1364
Once I resolved the duplicate entries by removing them from osti_user
, I was able to access the users in the admin portal again however now when my user goes to log in, the following error is generated:
[INSERT INTO `osti_user_account` SET `user_id` = 147, `timezone` = 'America/Vancouver', `username` = 'user@company.com', `backend` = 'oauth2.user.p8i3', `status` = 1]
Duplicate entry 'user@company.com' for key 'osti_user_account.username'<br />
<br />
---- Backtrace ----<br />
#0 (root)/include/mysqli.php(207): osTicket->logDBError()<br />
#1 (root)/include/class.orm.php(3482): db_query()<br />
#2 (root)/include/class.orm.php(658): MySqlExecutor->execute()<br />
#3 (root)/include/class.user.php(1220): VerySimpleModel->save()<br />
#4 (root)/include/class.user.php(1112): UserAccount->save()<br />
#5 (root)/include/class.auth.php(154): UserAccount->confirm()<br />
#6 phar://(root)/include/plugins/auth-oauth2.phar/oauth2.php(255): ClientCreateRequest->attemptAutoRegister()<br />
#7 phar://(root)/include/plugins/auth-oauth2.phar/oauth2.php(99): OAuth2UserAuthBackend->signIn()<br />
#8 phar://(root)/include/plugins/auth-oauth2.phar/auth.php(34): OAuth2UserAuthBackend->callback()<br />
#9 (root)/include/class.dispatcher.php(153): OAuth2Plugin::{closure}()<br />
#10 (root)/include/class.dispatcher.php(40): UrlMatcher->dispatch()<br />
#11 (root)/api/http.php(29): Dispatcher->resolve()<br />
#12 {main}
I removed the duplicate entry from osti_user_account
, and the user is able to log in the first time.
However, the second time they sign in, the same problem occurs.
It is as though osTicket does not realize this user is already registered.
How can I resolve this without creating a new user account for each user? There are hundreds of tickets and to go through and re-assign the ownership of each one would be way too time consuming.