mirror of
https://gitlab.com/mysocialportal/relatica
synced 2024-10-18 11:13:31 +00:00
Restore sign-in changes to fix username/email confusion
This commit is contained in:
parent
f5baecc87c
commit
ea13e1129c
1 changed files with 240 additions and 230 deletions
|
@ -61,8 +61,7 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
void _updateSignInButtonStatus() {
|
||||
setState(() {
|
||||
signInButtonEnabled = switch (oauthType) {
|
||||
usernamePasswordType =>
|
||||
serverNameController.text.isNotEmpty &&
|
||||
usernamePasswordType => serverNameController.text.isNotEmpty &&
|
||||
usernameController.text.isNotEmpty &&
|
||||
passwordController.text.isNotEmpty,
|
||||
oauthType => serverNameController.text.isNotEmpty,
|
||||
|
@ -141,14 +140,15 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
child: Form(
|
||||
key: formKey,
|
||||
child: Center(
|
||||
child: AutofillGroup(
|
||||
child: ListView(
|
||||
children: [
|
||||
Center(
|
||||
child: DropdownButton<String>(
|
||||
value: authType,
|
||||
items: authTypes
|
||||
.map(
|
||||
(a) => DropdownMenuItem(value: a, child: Text(a)))
|
||||
.map((a) =>
|
||||
DropdownMenuItem(value: a, child: Text(a)))
|
||||
.toList(),
|
||||
onChanged: existingAccount
|
||||
? null
|
||||
|
@ -174,10 +174,7 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
hintText: 'Server Name (friendica.example.com)',
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme
|
||||
.of(context)
|
||||
.colorScheme
|
||||
.surface,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
),
|
||||
|
@ -188,8 +185,7 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
if (!showUsernameAndPasswordFields) ...[
|
||||
Text(
|
||||
existingAccount
|
||||
? 'Configured to sign in as user ${existingProfile
|
||||
?.handle}'
|
||||
? 'Configured to sign in as user ${existingProfile?.handle}'
|
||||
: 'Relatica will open the requested Friendica site in a web browser where you will be asked to authorize this client.',
|
||||
softWrap: true,
|
||||
),
|
||||
|
@ -199,6 +195,7 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
TextFormField(
|
||||
readOnly: existingAccount,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
autofillHints: const [AutofillHints.username],
|
||||
controller: usernameController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator: (value) {
|
||||
|
@ -207,9 +204,15 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
}
|
||||
|
||||
if (value.contains('@')) {
|
||||
return isEmail(value)
|
||||
? null
|
||||
: 'Not a valid Friendica Account Address';
|
||||
final properFormat = isEmail(value);
|
||||
if (!properFormat) {
|
||||
return 'Not a valid Friendica Account Address';
|
||||
}
|
||||
final elements = value.split('@');
|
||||
if (elements.last != serverNameController.text) {
|
||||
return 'Server name must match above field.\nUsername should be the *Friendica* username.\nThis is not the email address of the account.';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return isAlphanumeric(value.replaceAll('-', ''))
|
||||
|
@ -218,13 +221,11 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
},
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.alternate_email),
|
||||
hintText: 'Username (user@example.com)',
|
||||
hintText:
|
||||
'Your username on the server (not email address)',
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme
|
||||
.of(context)
|
||||
.colorScheme
|
||||
.surface,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
),
|
||||
|
@ -236,6 +237,7 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
readOnly: existingAccount,
|
||||
obscureText: hidePassword,
|
||||
controller: passwordController,
|
||||
autofillHints: const [AutofillHints.password],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Password field cannot be empty';
|
||||
|
@ -258,10 +260,7 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
hintText: 'Password',
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme
|
||||
.of(context)
|
||||
.colorScheme
|
||||
.surface,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
),
|
||||
|
@ -275,14 +274,11 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
onPressed: () async => await _signIn(context),
|
||||
child: const Text('Signin'),
|
||||
)
|
||||
: const SizedBox(),
|
||||
: SizedBox(),
|
||||
const VerticalPadding(),
|
||||
Text(
|
||||
'Logged out:',
|
||||
style: Theme
|
||||
.of(context)
|
||||
.textTheme
|
||||
.headlineSmall,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
loggedOutProfiles.isEmpty
|
||||
? const Text(
|
||||
|
@ -308,7 +304,8 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
: oauthType),
|
||||
trailing: ElevatedButton(
|
||||
onPressed: () async {
|
||||
final confirm = await showYesNoDialog(context,
|
||||
final confirm = await showYesNoDialog(
|
||||
context,
|
||||
'Remove login information from app?');
|
||||
if (confirm ?? false) {
|
||||
await service.removeProfile(p);
|
||||
|
@ -324,10 +321,7 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
const VerticalPadding(),
|
||||
Text(
|
||||
'Logged in:',
|
||||
style: Theme
|
||||
.of(context)
|
||||
.textTheme
|
||||
.headlineSmall,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
loggedInProfiles.isEmpty
|
||||
? const Text(
|
||||
|
@ -383,11 +377,26 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
}).toList(),
|
||||
),
|
||||
),
|
||||
const VerticalPadding(),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final confirm = await showYesNoDialog(context,
|
||||
'Are you sure you want to logout and delete *all* accounts? This cannot be undone.') ??
|
||||
false;
|
||||
print(confirm);
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
|
||||
await getIt<AccountsService>().clearAllProfiles();
|
||||
},
|
||||
child: Text('Clear All')),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -405,8 +414,9 @@ class _SignInScreenState extends State<SignInScreen> {
|
|||
} else {
|
||||
switch (authType) {
|
||||
case usernamePasswordType:
|
||||
final username = usernameController.text.split('@').first;
|
||||
creds = BasicCredentials(
|
||||
username: usernameController.text,
|
||||
username: username,
|
||||
password: passwordController.text,
|
||||
serverName: serverNameController.text);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue