Verify state on login
This fixes "already logged in errors" if you started logging in before cancelling, and then trying again.
This commit is contained in:
parent
4e208764f5
commit
51430d2830
3 changed files with 17 additions and 7 deletions
|
|
@ -23,10 +23,8 @@ class AuthUrlController extends AsyncNotifier<OAuthAuthCodeResponse> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
static final provider =
|
static final provider = AsyncNotifierProvider.family
|
||||||
AsyncNotifierProvider.family<
|
.autoDispose<AuthUrlController, OAuthAuthCodeResponse, Uri>(
|
||||||
AuthUrlController,
|
AuthUrlController.new,
|
||||||
OAuthAuthCodeResponse,
|
);
|
||||||
Uri
|
|
||||||
>(AuthUrlController.new);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,9 @@ class SelectServerPage extends HookConsumerWidget {
|
||||||
await ref.watch(LaunchHelper.provider).launchUrl(codeResponse.url);
|
await ref.watch(LaunchHelper.provider).launchUrl(codeResponse.url);
|
||||||
|
|
||||||
AppLinks().uriLinkStream.listen((encodedUri) async {
|
AppLinks().uriLinkStream.listen((encodedUri) async {
|
||||||
|
final state = encodedUri.queryParameters["state"];
|
||||||
|
if (state != codeResponse.state) return;
|
||||||
|
|
||||||
final code = encodedUri.queryParameters["code"];
|
final code = encodedUri.queryParameters["code"];
|
||||||
|
|
||||||
if (code != null) {
|
if (code != null) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import "package:flutter/material.dart";
|
||||||
import "package:flutter_hooks/flutter_hooks.dart";
|
import "package:flutter_hooks/flutter_hooks.dart";
|
||||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||||
import "package:nexus/controllers/client.dart";
|
import "package:nexus/controllers/client.dart";
|
||||||
|
import "package:nexus/pages/settings.dart";
|
||||||
import "package:nexus/widgets/appbar.dart";
|
import "package:nexus/widgets/appbar.dart";
|
||||||
import "package:nexus/helpers/required_validator_helper.dart";
|
import "package:nexus/helpers/required_validator_helper.dart";
|
||||||
|
|
||||||
|
|
@ -32,7 +33,15 @@ class VerifyPage extends HookConsumerWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: Appbar(),
|
appBar: Appbar(
|
||||||
|
actions: .new([
|
||||||
|
IconButton(
|
||||||
|
onPressed: () =>
|
||||||
|
showDialog(context: context, builder: (_) => SettingsPage()),
|
||||||
|
icon: Icon(Icons.settings),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
body: AlertDialog(
|
body: AlertDialog(
|
||||||
title: Text("Verify"),
|
title: Text("Verify"),
|
||||||
content: Form(
|
content: Form(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue