osTicket / osTicket-plugins

Core plugins for osTicket (v1.8+)
GNU General Public License v2.0
148 stars 162 forks source link

Oauth Plug-in - Deleting a user didn't remove it from ost_user_account #278

Closed slysiou closed 1 year ago

slysiou commented 1 year ago

After deleting a user created during connection using oauth provider, the new connection doesn't work. After checking logs, I discover the issue:

[INSERT INTO ost_user_account SET user_id = 8, timezone = 'Europe/Berlin', username = 'xxx@xxx.com', backend = 'oauth2.user.p1i1', status = 1] Duplicate entry 'xxx@xxx.com' for key 'username'

---- Backtrace ----
#0 (root)/include/mysqli.php(211): osTicket->logDBError()
#1 (root)/include/class.orm.php(3482): db_query()
#2 (root)/include/class.orm.php(658): MySqlExecutor->execute()
#3 (root)/include/class.user.php(1220): VerySimpleModel->save()
#4 (root)/include/class.user.php(1112): UserAccount->save()
#5 (root)/include/class.auth.php(154): UserAccount->confirm()
#6 phar://(root)/include/plugins/auth-oauth2.phar/oauth2.php(248): ClientCreateRequest->attemptAutoRegister()
#7 phar://(root)/include/plugins/auth-oauth2.phar/oauth2.php(96): OAuth2UserAuthBackend->signIn()
#8 phar://(root)/include/plugins/auth-oauth2.phar/auth.php(34): OAuth2UserAuthBackend->callback()
#9 (root)/include/class.dispatcher.php(153): OAuth2Plugin::{closure}()
#10 (root)/include/class.dispatcher.php(40): UrlMatcher->dispatch()
#11 (root)/api/http.php(29): Dispatcher->resolve()
#12 {main}

After removing in ost_user_account table the record. New connection works for this user.

I think deleting user was not expected in the code. more logs on the auth0 process will be appreciated ;-)

slysiou commented 1 year ago

I realise this append when oauth plug configuration change between first connection and deleting user only.