xtuple/qt-client — pull request #488 by krauseo (2014-09-21 22:10:48+00:00)
Title: Issue22361 - correctly store roles added to new user from CRM account

What's happening now is that cramacct.cpp doesn't pass a username parameter to user.cpp, is just sends the crmacct_id and mode = "new". User.cpp, in its sPopulate() function, gets lower(crmacct_number), sets the text of the _username screen field to that value, and disables the _username field. However, what it doesn't do is set the _cUsername variable to that value. Because _cUsername does not get set, what the system is doing now when you add a role to a new user is calling grantgroup.sql using '' as the username parameter, and it's storing a usrgrp record with the right role id but with a blank username.

The changes committed here for review set _cUsername once it's derived from crmacct_number, then check to make sure the username begins with a letter, then get out of sCheck when adding a user to prevent throwing an error later in that function when it goes looking for the user record.

Having _cUsername set puts the right parameter value into the call to grantgroup and the right value into the usrgrp record.