Validate password before creating user

This commit is contained in:
Jason Ertel
2020-09-18 08:29:30 -04:00
parent 0c12025599
commit 1610445b4e

View File

@@ -90,14 +90,16 @@ function validateEmail() {
function updatePassword() { function updatePassword() {
identityId=$1 identityId=$1
# Read password from stdin (show prompt only if no stdin was piped in) if [ -z "$password" ]; then
test -t 0 # Read password from stdin (show prompt only if no stdin was piped in)
if [[ $? == 0 ]]; then test -t 0
echo "Enter new password:" if [[ $? == 0 ]]; then
fi echo "Enter new password:"
read -s password fi
read -s password
validatePassword "$password" validatePassword "$password"
fi
if [[ -n $identityId ]]; then if [[ -n $identityId ]]; then
# Generate password hash # Generate password hash
@@ -199,6 +201,7 @@ case "${operation}" in
[[ "$email" == "" ]] && fail "Email address must be provided" [[ "$email" == "" ]] && fail "Email address must be provided"
validateEmail "$email" validateEmail "$email"
updatePassword
createUser "$email" createUser "$email"
echo "Successfully added new user to SOC" echo "Successfully added new user to SOC"
check_container thehive && echo $password | so-thehive-user-add "$email" check_container thehive && echo $password | so-thehive-user-add "$email"