fix shell linebreaks, ignore empty names

This commit is contained in:
Christian Staudte 2020-11-03 22:56:50 +01:00
parent 2ab458f044
commit 8743fd12a5
Signed by: christian.staudte
GPG key ID: 88ED5070FE0D5F23
2 changed files with 9 additions and 6 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
config.ini
local/

View file

@ -22,8 +22,10 @@ class AbstimmIDd {
return ["error" => "event not found"];
}
foreach($body->user_names as $name) {
$hash = $this->get_hash($event_id, $vote_round, $name);
$result[] = ["round" => $vote_round, "user_name" => $name, "hash" => $hash];
if (strlen($name) > 0) {
$hash = $this->get_hash($event_id, $vote_round, $name);
$result[] = ["round" => $vote_round, "user_name" => $name, "hash" => $hash];
}
}
return $result;
}
@ -57,10 +59,10 @@ class AbstimmIDd {
$name = addslashes($name);
// generate the hash (the PHP password_hash function does not provide the required options)
$hash = shell_exec("echo -n '$name' | argon2 'Abstimmung $vote_round'
-p {$this->cfg["argon2"]["threads"]}
-m {$this->cfg["argon2"]["memory"]}
-t {$this->cfg["argon2"]["iterations"]}
$hash = shell_exec("echo -n '$name' | argon2 'Abstimmung $vote_round' \
-p {$this->cfg["argon2"]["threads"]} \
-m {$this->cfg["argon2"]["memory"]} \
-t {$this->cfg["argon2"]["iterations"]} \
-l {$this->cfg["argon2"]["length"]} -id -r");
$hash = str_replace(array("\n", "\r"), '', $hash);