Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions commet/lib/ui/pages/login/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:commet/utils/debounce.dart';
import 'package:commet/utils/rng.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:commet/ui/navigation/adaptive_dialog.dart';

class LoginPage extends StatefulWidget {
const LoginPage({super.key, this.onSuccess, this.canNavigateBack = false});
Expand All @@ -19,15 +20,16 @@ class LoginPage extends StatefulWidget {
State<LoginPage> createState() => LoginPageState();
}


class LoginPageState extends State<LoginPage> {
String get messageLoginFailed => Intl.message("Login Failed...",
name: "messageLoginFailed",
desc: "Generic text to show that an attempted login has failed");

String get messageLoginError => Intl.message("An error occured",
name: "messageLoginError",
String get messageLoginIncorrect => Intl.message("Incorrect username or password.",
name: "messageLoginIncorrect",
desc:
"A generic error message to convey that an error occured when attempting to login");
"A generic error message to convey that an error occured when attempting to login, usually an invalid username or password.");

String get messageAlreadyLoggedIn => Intl.message(
"You have already logged in to this account",
Expand Down Expand Up @@ -109,20 +111,21 @@ class LoginPageState extends State<LoginPage> {
String? message = switch (result) {
LoginResult.success => null,
LoginResult.failed => messageLoginFailed,
LoginResult.error => messageLoginError,
LoginResult.error => messageLoginIncorrect,
LoginResult.alreadyLoggedIn => messageAlreadyLoggedIn,
LoginResult.cancelled => "Login cancelled"
};

if (message != null) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(message),
),
);
AdaptiveDialog.show(
context,
title: "Login failed",
builder: (_) => Text("Incorrect login. Ensure that you have entered your username and password correctly, and that you have entered the homeserver address correctly.")
);
};
}
}


if (result == LoginResult.success) {
clientManager?.addClient(loginClient!);
Expand Down
Loading