Skip to content

Commit

Permalink
fix bug crashing the api when creating a user with ROLE_USER
Browse files Browse the repository at this point in the history
  • Loading branch information
randomchars42 committed Jun 17, 2017
1 parent c795c13 commit 18dd151
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/OlmServer/OlmApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -1293,8 +1293,22 @@ public function controllerUsersPost(\Symfony\Component\HttpFoundation\Request $r
$data['enabled'] = 0;
$data = $this->entriesPrepareForClient(array($data), 'users')[0];


$table = 'users';
$data = $this->checkData($data, $table, true);
$this->checkPermissionsRole($request->get("_route"));

$id = $this->entryCreate($data, $table);

if ($id === -1) {
$this->sendError(self::RESPONSE_ITEM_EXISTS);
}

mail($data['email'], '[Olm] PW', "Hallo " . $data['username'] . ",\nbitte melde Dich mit: $password an und ändere Dein Passwort!");
return $this->controllerDefaultPost($request, $data);
$entry = $this->entryFetchById($id, $table);
$entry = $this->entriesPrepareForClient(array($entry), $table)[0];

return $this->app->json($entry, 201);
}

public function controllerUsersPatch(\Symfony\Component\HttpFoundation\Request $request, string $id) {
Expand Down

0 comments on commit 18dd151

Please sign in to comment.