commit 0ae04a9722b7aaa1aca6db18b3ccf05cf7da6891 parent ad58e4b395b456fbabf97061990d99d76bea5cca Author: Martin Schanzenbach <schanzen@gnunet.org> Date: Fri, 10 Jan 2025 10:29:51 +0100 add phone validator Diffstat:
| A | scripts/validators/taldir-validate-phone | | | 45 | +++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 45 insertions(+), 0 deletions(-)
diff --git a/scripts/validators/taldir-validate-phone b/scripts/validators/taldir-validate-phone @@ -0,0 +1,45 @@ +#!/bin/bash +# This file is in the public domain. +set -eu + +# Check shared secrets +if [ -x "$TELESIGN_AUTH_TOKEN" ] +then + echo "TELESIGN_AUTH_TOKEN not sent in environment" + exit 1 +fi + +USER_MAIL=$1 +CODE=$2 +LINK=$(taldir-cli -l -a $1 -c $2) + +MESSAGE=" +Hi, + +welcome to TalDir. You are almost there. +Your registration code is $CODE. +Follow this link to complete your Taldir registration: $LINK + +Best, +TalDir +" + +TMPFILE=$(mktemp /tmp/sms-loggingXXXXXX) +STATUS=$(curl --request POST \ + --url https://rest-api.telesign.com/v1/messaging \ + --header "authorization: Basic $TELESIGN_AUTH_TOKEN" \ + --header 'content-type: application/x-www-form-urlencoded' \ + --data account_livecycle_event=transact \ + --data "message=$MESSAGE" \ + --data message_type=OTP \ + --data "phone_number=$1" \ + -w "%{http_code}" -s -o $TMPFILE) +case $STATUS in + 200|203|250|290|291|295) + exit 0; + ;; + *) + exit 1; + ;; +esac +exit 1