Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

DebugMode: Add support to pick creds from env

Neeraj Guptad263bafe567d
diff --git a/lib/ui/account/login_page.dart b/lib/ui/account/login_page.dart
index ca80a6c15a..c52f461d1c 100644
--- a/lib/ui/account/login_page.dart
+++ b/lib/ui/account/login_page.dart
@@ -1,4 +1,5 @@
import 'package:email_validator/email_validator.dart';
+import "package:flutter/foundation.dart";
import 'package:flutter/material.dart';
import "package:logging/logging.dart";
import 'package:photos/core/configuration.dart';
@@ -28,7 +29,11 @@ class _LoginPageState extends State<LoginPage> {
@override
void initState() {
- _email = _config.getEmail();
+ if ((_config.getEmail() ?? '').isNotEmpty) {
+ updateEmail(_config.getEmail()!);
+ } else if (kDebugMode) {
+ updateEmail(const String.fromEnvironment("email"));
+ }
super.initState();
}
@@ -143,19 +148,12 @@ class _LoginPageState extends State<LoginPage> {
),
onChanged: (value) {
setState(() {
- _email = value.trim();
- _emailIsValid = EmailValidator.validate(_email!);
- if (_emailIsValid) {
- _emailInputFieldColor =
- const Color.fromRGBO(45, 194, 98, 0.2);
- } else {
- _emailInputFieldColor = null;
- }
+ updateEmail(value);
});
},
autocorrect: false,
keyboardType: TextInputType.emailAddress,
- //initialValue: _email,
+ initialValue: _email,
autofocus: true,
),
),
@@ -179,31 +177,33 @@ class _LoginPageState extends State<LoginPage> {
.copyWith(fontSize: 12),
tags: {
'u-terms': StyledTextActionTag(
- (String? text, Map<String?, String?> attrs) => Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return WebPage(
- S.of(context).termsOfServicesTitle,
- "https://ente.io/terms",
- );
- },
- ),
+ (String? text, Map<String?, String?> attrs) =>
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return WebPage(
+ S.of(context).termsOfServicesTitle,
+ "https://ente.io/terms",
+ );
+ },
),
+ ),
style: const TextStyle(
decoration: TextDecoration.underline,
),
),
'u-policy': StyledTextActionTag(
- (String? text, Map<String?, String?> attrs) => Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return WebPage(
- S.of(context).privacyPolicyTitle,
- "https://ente.io/privacy",
- );
- },
- ),
+ (String? text, Map<String?, String?> attrs) =>
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return WebPage(
+ S.of(context).privacyPolicyTitle,
+ "https://ente.io/privacy",
+ );
+ },
),
+ ),
style: const TextStyle(
decoration: TextDecoration.underline,
),
@@ -226,4 +226,14 @@ class _LoginPageState extends State<LoginPage> {
],
);
}
+
+ void updateEmail(String value) {
+ _email = value.trim();
+ _emailIsValid = EmailValidator.validate(_email!);
+ if (_emailIsValid) {
+ _emailInputFieldColor = const Color.fromRGBO(45, 194, 98, 0.2);
+ } else {
+ _emailInputFieldColor = null;
+ }
+ }
}
diff --git a/lib/ui/account/login_pwd_verification_page.dart b/lib/ui/account/login_pwd_verification_page.dart
index 20c04ceff5..f29827a31f 100644
--- a/lib/ui/account/login_pwd_verification_page.dart
+++ b/lib/ui/account/login_pwd_verification_page.dart
@@ -1,4 +1,4 @@
-
+import "package:flutter/foundation.dart";
import 'package:flutter/material.dart';
import 'package:photos/core/configuration.dart';
import "package:photos/generated/l10n.dart";
@@ -15,14 +15,17 @@ import "package:photos/utils/dialog_util.dart";
// volatile password.
class LoginPasswordVerificationPage extends StatefulWidget {
final SrpAttributes srpAttributes;
- const LoginPasswordVerificationPage({Key? key, required this.srpAttributes}) : super(key: key);
+
+ const LoginPasswordVerificationPage({Key? key, required this.srpAttributes})
+ : super(key: key);
@override
- State<LoginPasswordVerificationPage> createState() => _LoginPasswordVerificationPageState();
+ State<LoginPasswordVerificationPage> createState() =>
+ _LoginPasswordVerificationPageState();
}
-class _LoginPasswordVerificationPageState extends
-State<LoginPasswordVerificationPage> {
+class _LoginPasswordVerificationPageState
+ extends State<LoginPasswordVerificationPage> {
final _passwordController = TextEditingController();
final FocusNode _passwordFocusNode = FocusNode();
String? email;
@@ -33,6 +36,9 @@ State<LoginPasswordVerificationPage> {
void initState() {
super.initState();
email = Configuration.instance.getEmail();
+ if (kDebugMode) {
+ _passwordController.text = const String.fromEnvironment("password");
+ }
_passwordFocusNode.addListener(() {
setState(() {
_passwordInFocus = _passwordFocusNode.hasFocus;
@@ -79,9 +85,11 @@ State<LoginPasswordVerificationPage> {
buttonText: S.of(context).logInLabel,
onPressedFunction: () async {
FocusScope.of(context).unfocus();
- await UserService.instance.verifyEmailViaPassword(context, widget
- .srpAttributes,
- _passwordController.text,);
+ await UserService.instance.verifyEmailViaPassword(
+ context,
+ widget.srpAttributes,
+ _passwordController.text,
+ );
},
),
floatingActionButtonLocation: fabLocation(),
@@ -97,17 +105,22 @@ State<LoginPasswordVerificationPage> {
child: ListView(
children: [
Padding(
- padding:
- const EdgeInsets.only(top: 30, left: 20, right: 20),
+ padding: const EdgeInsets.only(top: 30, left: 20, right: 20),
child: Text(
S.of(context).enterPassword,
style: Theme.of(context).textTheme.headlineMedium,
),
),
Padding(
- padding: const EdgeInsets.only(bottom: 30, left: 22, right:
- 20,),
- child: Text(email ?? '', style: getEnteTextTheme(context).smallMuted,),
+ padding: const EdgeInsets.only(
+ bottom: 30,
+ left: 22,
+ right: 20,
+ ),
+ child: Text(
+ email ?? '',
+ style: getEnteTextTheme(context).smallMuted,
+ ),
),
Visibility(
// hidden textForm for suggesting auto-fill service for saving
@@ -138,19 +151,19 @@ State<LoginPasswordVerificationPage> {
),
suffixIcon: _passwordInFocus
? IconButton(
- icon: Icon(
- _passwordVisible
- ? Icons.visibility
- : Icons.visibility_off,
- color: Theme.of(context).iconTheme.color,
- size: 20,
- ),
- onPressed: () {
- setState(() {
- _passwordVisible = !_passwordVisible;
- });
- },
- )
+ icon: Icon(
+ _passwordVisible
+ ? Icons.visibility
+ : Icons.visibility_off,
+ color: Theme.of(context).iconTheme.color,
+ size: 20,
+ ),
+ onPressed: () {
+ setState(() {
+ _passwordVisible = !_passwordVisible;
+ });
+ },
+ )
: null,
),
style: const TextStyle(
@@ -181,9 +194,11 @@ State<LoginPasswordVerificationPage> {
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () async {
- await UserService.instance
- .sendOtt(context, email!,
- isResetPasswordScreen: true,);
+ await UserService.instance.sendOtt(
+ context,
+ email!,
+ isResetPasswordScreen: true,
+ );
},
child: Center(
child: Text(
@@ -192,9 +207,9 @@ State<LoginPasswordVerificationPage> {
.textTheme
.titleMedium!
.copyWith(
- fontSize: 14,
- decoration: TextDecoration.underline,
- ),
+ fontSize: 14,
+ decoration: TextDecoration.underline,
+ ),
),
),
),
@@ -218,9 +233,9 @@ State<LoginPasswordVerificationPage> {
.textTheme
.titleMedium!
.copyWith(
- fontSize: 14,
- decoration: TextDecoration.underline,
- ),
+ fontSize: 14,
+ decoration: TextDecoration.underline,
+ ),
),
),
),
@@ -234,4 +249,4 @@ State<LoginPasswordVerificationPage> {
],
);
}
-}
\ No newline at end of file
+}