Sign up: Add field for 'hear us from' info (#376)
This commit is contained in:
parent
7fe314a16a
commit
d02e02a326
|
@ -402,5 +402,7 @@
|
||||||
"signOutFromOtherDevices": "Sign out from other devices",
|
"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.",
|
"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",
|
"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!"
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ import "package:uuid/uuid.dart";
|
||||||
class UserService {
|
class UserService {
|
||||||
static const keyHasEnabledTwoFactor = "has_enabled_two_factor";
|
static const keyHasEnabledTwoFactor = "has_enabled_two_factor";
|
||||||
static const keyUserDetails = "user_details";
|
static const keyUserDetails = "user_details";
|
||||||
|
static const kReferralSource = "referral_source";
|
||||||
static const kCanDisableEmailMFA = "can_disable_email_mfa";
|
static const kCanDisableEmailMFA = "can_disable_email_mfa";
|
||||||
static const kIsEmailMFAEnabled = "is_email_mfa_enabled";
|
static const kIsEmailMFAEnabled = "is_email_mfa_enabled";
|
||||||
final SRP6GroupParameters kDefaultSrpGroup = SRP6StandardGroups.rfc5054_4096;
|
final SRP6GroupParameters kDefaultSrpGroup = SRP6StandardGroups.rfc5054_4096;
|
||||||
|
@ -270,13 +271,17 @@ class UserService {
|
||||||
}) async {
|
}) async {
|
||||||
final dialog = createProgressDialog(context, context.l10n.pleaseWait);
|
final dialog = createProgressDialog(context, context.l10n.pleaseWait);
|
||||||
await dialog.show();
|
await dialog.show();
|
||||||
|
final verifyData = {
|
||||||
|
"email": _config.getEmail(),
|
||||||
|
"ott": ott,
|
||||||
|
};
|
||||||
|
if (!_config.isLoggedIn()) {
|
||||||
|
verifyData["source"] = 'auth:' + _getRefSource();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
final response = await _dio.post(
|
final response = await _dio.post(
|
||||||
_config.getHttpEndpoint() + "/users/verify-email",
|
_config.getHttpEndpoint() + "/users/verify-email",
|
||||||
data: {
|
data: verifyData,
|
||||||
"email": _config.getEmail(),
|
|
||||||
"ott": ott,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
await dialog.hide();
|
await dialog.hide();
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
@ -890,4 +895,12 @@ class UserService {
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> setRefSource(String refSource) async {
|
||||||
|
await _preferences.setString(kReferralSource, refSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _getRefSource() {
|
||||||
|
return _preferences.getString(kReferralSource) ?? "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,10 @@ import 'package:ente_auth/core/configuration.dart';
|
||||||
import 'package:ente_auth/ente_theme_data.dart';
|
import 'package:ente_auth/ente_theme_data.dart';
|
||||||
import 'package:ente_auth/l10n/l10n.dart';
|
import 'package:ente_auth/l10n/l10n.dart';
|
||||||
import 'package:ente_auth/services/user_service.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/dynamic_fab.dart';
|
||||||
import 'package:ente_auth/ui/common/web_page.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/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:password_strength/password_strength.dart';
|
import 'package:password_strength/password_strength.dart';
|
||||||
|
@ -30,6 +32,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
||||||
String? _email;
|
String? _email;
|
||||||
String? _password;
|
String? _password;
|
||||||
String _cnfPassword = '';
|
String _cnfPassword = '';
|
||||||
|
String _referralSource = '';
|
||||||
double _passwordStrength = 0.0;
|
double _passwordStrength = 0.0;
|
||||||
bool _emailIsValid = false;
|
bool _emailIsValid = false;
|
||||||
bool _hasAgreedToTOS = true;
|
bool _hasAgreedToTOS = true;
|
||||||
|
@ -104,6 +107,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
||||||
onPressedFunction: () {
|
onPressedFunction: () {
|
||||||
_config.setVolatilePassword(_passwordController1.text);
|
_config.setVolatilePassword(_passwordController1.text);
|
||||||
UserService.instance.setEmail(_email!);
|
UserService.instance.setEmail(_email!);
|
||||||
|
UserService.instance.setRefSource(_referralSource);
|
||||||
UserService.instance
|
UserService.instance
|
||||||
.sendOtt(context, _email!, isCreateAccountScreen: true);
|
.sendOtt(context, _email!, isCreateAccountScreen: true);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
|
@ -325,6 +329,51 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
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 Divider(thickness: 1),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
_getAgreement(),
|
_getAgreement(),
|
||||||
|
|
Loading…
Reference in a new issue