Don't want to call it a bug but admins get deleted

When working on “administrators” if you edit lets say Bob, make some changes to his access rights and then go to save his user, IF you change the user name (Bob is reflected in the URL) to anything but bob, then you end up deleting Bob and get some DB errors.

Before you say, why would you change the user name dumb guy, well it’s not actually me that changes it, but a password utility thinks it knows how to help you and replaces the name Bob with in my case admin since it’s on that specific PBX URL. Now I’m ok with it not working because of the name change, because you’re trying to change the wrong users information, but it fails with an error and deletes the user Bob, which of course is a bit of pain to reconfigure all the individual settings but I’m also not sure what else could be affected.

I figured I would share this here, since it’s definitely not a bug per say.

FATAL ERROR

INSERT INTO ampusers (username, password_sha1, extension_low, extension_high, deptname, sections) VALUES ('admin','ffa20sdkj74565081ba54f9ee77','','','','*'); [nativecode=1062 ** Duplicate entry 'admin' for key 'PRIMARY']SQL - <br /> INSERT INTO ampusers (username, password_sha1, extension_low, extension_high, deptname, sections) VALUES ('admin','ffa208f1f79e5648dfpf9fba54f9ee77','','','','*');

Trace Back

/var/www/html/admin/libraries/sql.functions.php:25 die_freepbx()
  [0]: INSERT INTO ampusers (username, password_sha1, extension_low, extension_high, deptname, sections) VALUES ('admin','ffa208f1f79kjsdus74641ba54f9ee77','','','','*'); [nativecode=1062 ** Duplicate entry 'admin' for key 'PRIMARY']SQL - <br /> INSERT INTO ampusers (username, password_sha1, extension_low, extension_high, deptname, sections) VALUES ('admin','ffa208f1f79edb715ffdb0d9407081ba54f9ee77','','','','*');

/var/www/html/admin/modules/core/functions.inc.php:4226 sql()
  [0]: INSERT INTO ampusers (username, password_sha1, extension_low, extension_high, deptname, sections) VALUES ('admin','ffa208f165dkiuryfffdb0d9407081ba54f9ee77','','','','*');
  [1]: query

/var/www/html/admin/modules/core/page.ampusers.php:80 core_ampusers_add()
  [0]: admin
  [1]: kjsdlkfjsdf87983475kjhkjhk4353453
  [2]: 
  [3]: 
  [4]: 
  [5]: 

/var/www/html/admin/config.php:504 include()
  [0]: /var/www/html/admin/modules/core/page.ampusers.php

Please file a bug. Also anywhere else a “username” or “password” gets autopopulated by the browser feel free to submit a bug also. I have submitted a branch for framework that once merged will allow us to add special classes to these fields and with any luck bypass this “browser feature” until they circumvent the fix.

Also when you submit a potential duplicate as above we should not be deleting things nor throwing errors so it is a bug.

Will do!
FYI Applications like 1password, lastpass and of course the browsers themselves all play a role in this type of scenario.

Thanks!