forked from Nexus/nexus
OAuth Support (#53)
Rips out the old auth method, adds OAuth support. Fixes #51. Tested Platforms: - [x] Linux - [x] Flatpak - [x] Native (Nix) - [x] Android - [ ] Windows - [ ] MacOS Reviewed-on: Nexus/nexus#53
This commit is contained in:
parent
5df975f607
commit
7d106ad3a2
86 changed files with 558 additions and 1344 deletions
32
lib/controllers/auth_url.dart
Normal file
32
lib/controllers/auth_url.dart
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:nexus/controllers/client.dart";
|
||||
import "package:nexus/controllers/client_id.dart";
|
||||
import "package:nexus/models/oauth_auth_code_response.dart";
|
||||
import "package:nexus/models/requests/oauth/get_auth_url.dart";
|
||||
|
||||
class AuthUrlController extends AsyncNotifier<OAuthAuthCodeResponse> {
|
||||
final Uri homeserver;
|
||||
AuthUrlController(this.homeserver);
|
||||
|
||||
@override
|
||||
Future<OAuthAuthCodeResponse> build() async => ref
|
||||
.watch(ClientController.provider.notifier)
|
||||
.getAuthUrl(
|
||||
.new(
|
||||
homeserverUrl: homeserver,
|
||||
redirectUri: .new(scheme: "nexus.federated.nexus", path: "/"),
|
||||
responseMode: .query,
|
||||
scopes: .new([Scope.clientApi, Scope.device]),
|
||||
clientId: await ref.watch(
|
||||
ClientIdController.provider(homeserver).future,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
static final provider =
|
||||
AsyncNotifierProvider.family<
|
||||
AuthUrlController,
|
||||
OAuthAuthCodeResponse,
|
||||
Uri
|
||||
>(AuthUrlController.new);
|
||||
}
|
||||
Loading…
Reference in a new issue