Modify

Opened 2 years ago

Last modified 16 months ago

#10057 new defect

IntegrityError: (1062, "Duplicate entry 'name' for key 'username'")

Reported by: czarnymb Owned by: dolfandringa
Priority: normal Component: SqlFlexibleAuthStorePlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

How to Reproduce

While doing a POST operation on /prefs/account, Trac issued an internal error.

Additional details -- Password Changing in Profile Preferences

Request parameters:

{'__FORM_TOKEN': u'e39d7abe2c3679c7df5e4841',
 'action': u'save',
 'old_password': u'marek',
 'panel_id': u'account',
 'password': u'test',
 'password_confirm': u'test'}

User agent: Opera/9.80 (Windows NT 5.1; U; pl) Presto/2.10.229 Version/11.64

Python Traceback

Traceback (most recent call last):
  File "build\bdist.win32\egg\trac\web\main.py", line 522, in _dispatch_request
    dispatcher.dispatch(req)
  File "build\bdist.win32\egg\trac\web\main.py", line 243, in dispatch
    resp = chosen_handler.process_request(req)
  File "build\bdist.win32\egg\trac\prefs\web_ui.py", line 77, in process_request
    template, data = chosen_provider.render_preference_panel(req, panel_id)
  File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 225, in render_preference_panel
    data = {'account': self._do_account(req),
  File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 287, in _do_account
    data.update(self._do_change_password(req))
  File "build\bdist.win32\egg\acct_mgr\web_ui.py", line 357, in _do_change_password
    self.acctmgr.set_password(user, password, old_password)
  File "build\bdist.win32\egg\acct_mgr\api.py", line 295, in set_password
    self._notify('password_changed', user, password)
  File "build\bdist.win32\egg\acct_mgr\api.py", line 456, in _notify
    getattr(l, func)(*args)
  File "C:\Program Files\BitNami Trac Stack\python\lib\site-packages\sqlflexibleauthstoreplugin-0.1-py2.6.egg\sqlflexibleauthstore\sqlflexibleauthstore.py", line 299, in user_password_changed
    return self.set_password(user,password,create_user=True)
  File "C:\Program Files\BitNami Trac Stack\python\lib\site-packages\sqlflexibleauthstoreplugin-0.1-py2.6.egg\sqlflexibleauthstore\sqlflexibleauthstore.py", line 205, in set_password
    cursor.execute(query)
  File "build\bdist.win32\egg\trac\db\util.py", line 66, in execute
    return self.cursor.execute(sql)
  File "C:\Program Files\BitNami Trac Stack\python\lib\site-packages\MySQLdb\cursors.py", line 173, in execute
    self.errorhandler(self, exc, value)
  File "C:\Program Files\BitNami Trac Stack\python\lib\site-packages\MySQLdb\connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
IntegrityError: (1062, "Duplicate entry 'name' for key 'username'")

Attachments (0)

Change History (2)

comment:1 follow-up: Changed 2 years ago by czarnymb

When i've changed the line 299 in sqlflexibleauthstore.py from

return self.set_password(user,password,create_user=True)

to

return self.set_password(user,password,create_user=False)

it worked with no errors but... then I can't add new users...

comment:2 in reply to: ↑ 1 Changed 16 months ago by rjollos

Replying to czarnymb:

it worked with no errors but... then I can't add new users...

That is a bit surprising. I would expect that only user_created would be called when a user is created. You are changing code in the method user_password_changed, which should only be called when a password is changed for an existing user. What error do you see with regard to can't add new users?

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.