Commit 7ca910cd by Dirk Benkert

fixed bug where user already existed but get created again because autocomplete…

fixed bug where user already existed but get created again because autocomplete was not used during input
parent 1b3a0883
......@@ -82,24 +82,32 @@ class User extends AbstractService {
if (!is_numeric($userid)) {
if($validator->isValid($userid)) {
$user = new UserEntity();
$service = new Password();
$password = $service->generate();
$user->setData(array(
'email' => $userid,
'password' => $password,
'isadmin' => false,
'caninvite' => false,
'cancreatefolders' => false,
'canuploadfiles' => false,
'created' => time(),
'createdviainvite' => true
));
$this->getEntityManager()->persist($user);
$userid = $user->id;
$value = $user->id;
//try to find user via email, maybe someone did not use the autocomplete
$user = $this->getEntityManager()->getRepository('Application\Entity\User')->findOneBy(array('email' => $userid));
if (!$user) {
$user = new UserEntity();
$service = new Password();
$password = $service->generate();
$user->setData(array(
'email' => $userid,
'password' => $password,
'isadmin' => false,
'caninvite' => false,
'cancreatefolders' => false,
'canuploadfiles' => false,
'created' => time(),
'createdviainvite' => true
));
$this->getEntityManager()->persist($user);
$userid = $user->id;
$value = $user->id;
} else {
$userid = $user->id;
$value = $user->id;
$password = false;
}
} else {
$user = false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment