oauth2 state of mind
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:localstorage/localstorage.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/widgets/dialog/login.dart';
|
||||
import 'package:oc_front/core/conf/conf_reader.dart';
|
||||
import 'package:oc_front/core/sections/left_menu.dart';
|
||||
import 'package:oc_front/core/sections/end_drawer.dart';
|
||||
import 'package:oc_front/core/sections/header/menu.dart';
|
||||
import 'package:oc_front/core/services/auth.service.dart';
|
||||
import 'package:oc_front/core/services/oauth2.service.dart';
|
||||
import 'package:oc_front/core/services/enum_service.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/core/sections/header/menu.dart';
|
||||
import 'package:oc_front/core/sections/left_menu.dart';
|
||||
import 'package:oc_front/core/services/auth.service.dart';
|
||||
import 'package:oc_front/core/services/enum_service.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/core/sections/end_drawer.dart';
|
||||
import 'package:oc_front/widgets/dialog/login.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
// Run `LinuxWebViewPlugin.initialize()` first before creating a WebView.
|
||||
@@ -30,6 +31,7 @@ class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Future.delayed(Duration(seconds: 2), () => AppRouter.verifyRoute(context));
|
||||
AppConfig().loadConfig();
|
||||
AuthService.init();
|
||||
EnumService.init();
|
||||
SearchConstants.clear();
|
||||
@@ -56,11 +58,11 @@ class MainPage extends StatefulWidget {
|
||||
State<MainPage> createState() => MainPageState();
|
||||
}
|
||||
|
||||
var darkColor = Color.fromRGBO(26, 83, 92, 1);
|
||||
var lightColor = Color.fromRGBO(78, 205, 196, 1);
|
||||
var darkMidColor = Color.fromRGBO(44, 83, 100, 1);
|
||||
var midColor = Colors.grey.shade300;
|
||||
var redColor = Color.fromRGBO(255, 107, 107, 1);
|
||||
var darkColor = const Color.fromRGBO(26, 83, 92, 1);
|
||||
var lightColor = const Color.fromRGBO(78, 205, 196, 1);
|
||||
var darkMidColor = const Color.fromRGBO(44, 83, 100, 1);
|
||||
var midColor = Colors.grey.shade300;
|
||||
var redColor = const Color.fromRGBO(255, 107, 107, 1);
|
||||
|
||||
double getWidth(BuildContext context) {
|
||||
return MediaQuery.of(context).size.width <= 800
|
||||
@@ -99,10 +101,17 @@ class MainPageState extends State<MainPage> {
|
||||
// The Flutter framework has been optimized to make rerunning build methods
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.i
|
||||
|
||||
scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
if (!AuthService.isConnected() && !loginIsSet) {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
Future.delayed(const Duration(milliseconds: 500), () async {
|
||||
loginIsSet = true;
|
||||
// initFlow() returns the login_challenge from the URL if present,
|
||||
// or redirects the browser to Hydra's auth endpoint (web) and
|
||||
// returns null while the page reloads with ?login_challenge=<...>.
|
||||
final challenge = await OAuth2Service().initFlow();
|
||||
if (challenge == null) return;
|
||||
// ignore: use_build_context_synchronously
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
// ignore: use_build_context_synchronously
|
||||
@@ -112,7 +121,7 @@ class MainPageState extends State<MainPage> {
|
||||
backgroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(0)),
|
||||
title: LoginWidget());
|
||||
title: LoginWidget(loginChallenge: challenge));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -138,7 +147,6 @@ class MainPageState extends State<MainPage> {
|
||||
onKeyEvent: (event) async {
|
||||
if( (event is KeyDownEvent) && event.logicalKey == LogicalKeyboardKey.enter) {
|
||||
AppRouter.currentRoute.factory.search(context, false);
|
||||
node.requestFocus();
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
|
||||
Reference in New Issue
Block a user