[FIXED JENKINS-24317] Corrected user dir migration code from JENKINS-23872.
Adapted from #1375 by @daniel-beck: omitting change to User construction, and adding test.
(cherry picked from commit 088edabb31a90cd607f3c6a3123effce5703c817)

Conflicts:
	changelog.html