diff --git a/public/locales/en.json b/public/locales/en.json index 387c706..d2dc7e2 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -1,6 +1,5 @@ { "Transparency and Control Portal": "Transparency and Control Portal", - "This site allows you to opt out of targeted advertising based on Unified ID 2.0. Please enter your email below. You represent and warrant that this is your email.": "This site allows you to opt out of targeted advertising based on Unified ID 2.0. Please enter your email below. You represent and warrant that this is your email.", "Enter your email address": "Enter your email address", "NEXT": "NEXT", "Please enter a valid email address": "Please enter a valid email address", @@ -31,5 +30,9 @@ "NO": "NO", "This choice may limit your ability to access ad supported content.": "This choice may limit your ability to access ad supported content.", "You may be asked to Opt-In again in the future to access such content.": "You may be asked to Opt-In again in the future to access such content.", - "We have received your request to opt out and will begin processing it shortly.": "We have received your request to opt out and will begin processing it shortly." + "We have received your request to opt out and will begin processing it shortly.": "We have received your request to opt out and will begin processing it shortly.", + "Enter your phone number, e.g. +1111111111": "Enter your phone number, e.g. +1111111111", + "This site allows you to opt out of targeted advertising based on Unified ID 2.0. Please enter your email or phone number below. You represent and warrant that this is your information.": "This site allows you to opt out of targeted advertising based on Unified ID 2.0. Please enter your email or phone number below. You represent and warrant that this is your information.", + "Email Address": "Email Address", + "Phone Number": "Phone Number" } \ No newline at end of file diff --git a/public/locales/ja.json b/public/locales/ja.json index 8d7eded..9a039fc 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -1,6 +1,5 @@ { "Transparency and Control Portal": "透明性と管理ポータル", - "This site allows you to opt out of targeted advertising based on Unified ID 2.0. Please enter your email below. You represent and warrant that this is your email.": "このサイトでは、Unified ID 2.0を使ったターゲティング広告をオプトアウトすることができます。以下にあなたのメールアドレスを入力してください。確認のメールをお送りします。", "Enter your email address": "メールアドレスを入力してください", "NEXT": "次へ", "Please enter a valid email address": "有効なEメールアドレスを入力してください。", @@ -31,5 +30,9 @@ "NO": "いいえ", "This choice may limit your ability to access ad supported content.": "この選択により、広告付きコンテンツへのアクセスが制限される場合があります。", "You may be asked to Opt-In again in the future to access such content.": "将来、そのようなコンテンツにアクセスするために、再度オプトインを求められる可能性があります。", - "We have received your request to opt out and will begin processing it shortly.": "オプトアウトのリクエストを受け取りました。まもなく処理を開始します。" + "We have received your request to opt out and will begin processing it shortly.": "オプトアウトのリクエストを受け取りました。まもなく処理を開始します。", + "Enter your phone number, e.g. +1111111111": "電話番号を入力してください", + "This site allows you to opt out of targeted advertising based on Unified ID 2.0. Please enter your email or phone number below. You represent and warrant that this is your information.": "このサイトでは、Unified ID 2.0を使ったターゲティング広告をオプトアウトすることができます。以下にあなたのメールアドレスや電話番号を入力してください。確認のメールをお送りします。", + "Email Address": "メールアドレス", + "Phone Number": "電話番号" } diff --git a/public/stylesheets/index.css b/public/stylesheets/index.css index 549b9cb..9cdcea3 100644 --- a/public/stylesheets/index.css +++ b/public/stylesheets/index.css @@ -51,7 +51,7 @@ height: 40px; justify-content: flex-start; margin-right: 1.0px; - margin-top: 30px; + margin-top: 20px; min-width: 399px; padding: 0 16.0px; position: relative; diff --git a/src/routes/index.ts b/src/routes/index.ts index f247ab9..5d9b5b1 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -39,6 +39,12 @@ const isValidEmail = (email: string) => { return emailRegex.test(email); }; +const isValidPhone = (phone: string) => { + // eslint-disable-next-line no-control-regex + const phoneRegex = /^\+[0-9]{10,15}$/; + return phoneRegex.test(phone); +}; + const EmailPromptRequest = z.object({ email: z.string(), recaptcha: z.string(), @@ -46,8 +52,8 @@ const EmailPromptRequest = z.object({ const handleEmailPromptSubmission: RequestHandler<{}, z.infer, { email: string, encrypted: string, error?: string }> = async (req, res, _next) => { const { email, recaptcha } = EmailPromptRequest.parse(req.body); - if (!isValidEmail(email)) { - res.render('index', { email, error : i18n.__('Please enter a valid email address') }); + if (!isValidEmail(email) && !isValidPhone(email)) { + res.render('index', { email, error : i18n.__('Please enter a valid email address or phone number') }); return; } diff --git a/src/routes/optout.ts b/src/routes/optout.ts index f1b7209..f83ffce 100644 --- a/src/routes/optout.ts +++ b/src/routes/optout.ts @@ -25,8 +25,10 @@ import axios from 'axios'; import { OPTOUT_API_KEY, OPTOUT_ENDPOINT_URL } from '../utils/process'; -export async function optout(email: string): Promise { - const url = `${OPTOUT_ENDPOINT_URL}?email=${encodeURIComponent(email)}`; +export async function optout(identityInput: string): Promise { + const url = identityInput[0] == '+' + ? `${OPTOUT_ENDPOINT_URL}?phone=${encodeURIComponent(identityInput)}` + : `${OPTOUT_ENDPOINT_URL}?email=${encodeURIComponent(identityInput)}`; const response = await axios.get(url, { diff --git a/views/index.hbs b/views/index.hbs index f968088..3e0d80e 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -186,7 +186,7 @@
- {{__ "This site allows you to opt out of targeted advertising based on Unified ID 2.0. Please enter your email below. You represent and warrant that this is your email."}} + {{__ "This site allows you to opt out of targeted advertising based on Unified ID 2.0. Please enter your email or phone number below. You represent and warrant that this is your information."}}
{{#if error}}
@@ -202,8 +202,18 @@ {{{siteKeyInput}}} + +
+ +
+ +    + + +
+
- +