π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Sign up: Add field for 'hear us from' info (#376)
Neeraj Guptad02e02a32655
diff --git a/lib/l10n/arb/app_en.arb b/lib/l10n/arb/app_en.arbindex a4dda6b2f7..24429b195d 100644--- a/lib/l10n/arb/app_en.arb+++ b/lib/l10n/arb/app_en.arb@@ -402,5 +402,7 @@"signOutFromOtherDevices": "Sign out from other devices","signOutOtherBody": "If you think someone might know your password, you can force all other devices using your account to sign out.","signOutOtherDevices": "Sign out other devices",- "doNotSignOut": "Do not sign out"+ "doNotSignOut": "Do not sign out",+ "hearUsWhereTitle": "How did you hear about Ente? (optional)",+ "hearUsExplanation": "We don't track app installs. It'd help if you told us where you found us!"}diff --git a/lib/services/user_service.dart b/lib/services/user_service.dartindex 0bbbd81c78..49d386fec5 100644--- a/lib/services/user_service.dart+++ b/lib/services/user_service.dart@@ -45,6 +45,7 @@ import "package:uuid/uuid.dart";class UserService {static const keyHasEnabledTwoFactor = "has_enabled_two_factor";static const keyUserDetails = "user_details";+ static const kReferralSource = "referral_source";static const kCanDisableEmailMFA = "can_disable_email_mfa";static const kIsEmailMFAEnabled = "is_email_mfa_enabled";final SRP6GroupParameters kDefaultSrpGroup = SRP6StandardGroups.rfc5054_4096;@@ -270,13 +271,17 @@ class UserService {}) async {final dialog = createProgressDialog(context, context.l10n.pleaseWait);await dialog.show();+ final verifyData = {+ "email": _config.getEmail(),+ "ott": ott,+ };+ if (!_config.isLoggedIn()) {+ verifyData["source"] = 'auth:' + _getRefSource();+ }try {final response = await _dio.post(_config.getHttpEndpoint() + "/users/verify-email",- data: {- "email": _config.getEmail(),- "ott": ott,- },+ data: verifyData,);await dialog.hide();if (response.statusCode == 200) {@@ -890,4 +895,12 @@ class UserService {rethrow;}}++ Future<void> setRefSource(String refSource) async {+ await _preferences.setString(kReferralSource, refSource);+ }++ String _getRefSource() {+ return _preferences.getString(kReferralSource) ?? "";+ }}diff --git a/lib/ui/account/email_entry_page.dart b/lib/ui/account/email_entry_page.dartindex e6c3f41fb6..ce72f9262f 100644--- a/lib/ui/account/email_entry_page.dart+++ b/lib/ui/account/email_entry_page.dart@@ -3,8 +3,10 @@ import 'package:ente_auth/core/configuration.dart';import 'package:ente_auth/ente_theme_data.dart';import 'package:ente_auth/l10n/l10n.dart';import 'package:ente_auth/services/user_service.dart';+import 'package:ente_auth/theme/ente_theme.dart';import 'package:ente_auth/ui/common/dynamic_fab.dart';import 'package:ente_auth/ui/common/web_page.dart';+import 'package:ente_auth/utils/toast_util.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:password_strength/password_strength.dart';@@ -30,6 +32,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {String? _email;String? _password;String _cnfPassword = '';+ String _referralSource = '';double _passwordStrength = 0.0;bool _emailIsValid = false;bool _hasAgreedToTOS = true;@@ -104,6 +107,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {onPressedFunction: () {_config.setVolatilePassword(_passwordController1.text);UserService.instance.setEmail(_email!);+ UserService.instance.setRefSource(_referralSource);UserService.instance.sendOtt(context, _email!, isCreateAccountScreen: true);FocusScope.of(context).unfocus();@@ -325,6 +329,51 @@ class _EmailEntryPageState extends State<EmailEntryPage> {),),const SizedBox(height: 4),+ Padding(+ padding:+ const EdgeInsets.symmetric(vertical: 0, horizontal: 20),+ child: Text(+ context.l10n.hearUsWhereTitle,+ style: getEnteTextTheme(context).smallFaint,+ ),+ ),+ const SizedBox(height: 4),+ Padding(+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),+ child: TextFormField(+ style: Theme.of(context).textTheme.titleMedium,+ decoration: InputDecoration(+ fillColor: null,+ filled: true,+ contentPadding: const EdgeInsets.symmetric(+ horizontal: 16,+ vertical: 14,+ ),+ border: UnderlineInputBorder(+ borderSide: BorderSide.none,+ borderRadius: BorderRadius.circular(6),+ ),+ suffixIcon: InkWell(+ onTap: () {+ showToast(+ context,+ context.l10n.hearUsExplanation,+ );+ },+ child: Icon(+ Icons.info_outline_rounded,+ color: getEnteColorScheme(context).strokeMuted,+ ),+ ),+ ),+ onChanged: (value) {+ _referralSource = value.trim();+ },+ autocorrect: false,+ keyboardType: TextInputType.text,+ textInputAction: TextInputAction.next,+ ),+ ),const Divider(thickness: 1),const SizedBox(height: 12),_getAgreement(),