login debug
This commit is contained in:
parent
e73ca6b532
commit
2c86e90b76
@ -3,6 +3,7 @@ import 'package:localstorage/localstorage.dart';
|
|||||||
import 'package:oc_front/core/sections/header/header.dart';
|
import 'package:oc_front/core/sections/header/header.dart';
|
||||||
import 'package:oc_front/core/services/api_service.dart';
|
import 'package:oc_front/core/services/api_service.dart';
|
||||||
import 'package:oc_front/core/services/perms_service.dart';
|
import 'package:oc_front/core/services/perms_service.dart';
|
||||||
|
import 'package:oc_front/main.dart';
|
||||||
import 'package:oc_front/models/response.dart';
|
import 'package:oc_front/models/response.dart';
|
||||||
class AuthService {
|
class AuthService {
|
||||||
static var isAuth = const bool.fromEnvironment('AUTH_MODE', defaultValue: false);
|
static var isAuth = const bool.fromEnvironment('AUTH_MODE', defaultValue: false);
|
||||||
@ -60,7 +61,7 @@ class AuthService {
|
|||||||
|
|
||||||
static Future<void> logout() async {
|
static Future<void> logout() async {
|
||||||
var token = await service.delete("/ldap/logout", null);
|
var token = await service.delete("/ldap/logout", null);
|
||||||
if (token.code == 200 && token.data != null) {
|
if (token.code == 200) {
|
||||||
localStorage.setItem('accessToken', '');
|
localStorage.setItem('accessToken', '');
|
||||||
localStorage.setItem('username', '');
|
localStorage.setItem('username', '');
|
||||||
localStorage.setItem('expiresIn', '');
|
localStorage.setItem('expiresIn', '');
|
||||||
|
@ -86,14 +86,11 @@ class MainPageState extends State<MainPage> {
|
|||||||
//
|
//
|
||||||
// The Flutter framework has been optimized to make rerunning build methods
|
// The Flutter framework has been optimized to make rerunning build methods
|
||||||
// fast, so that you can just rebuild anything that needs updating rather
|
// fast, so that you can just rebuild anything that needs updating rather
|
||||||
// than having to individually change instances of widgets.
|
// than having to individually change instances of widgets.i
|
||||||
scaffoldKey = GlobalKey<ScaffoldState>();
|
scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
isCtrl = false;
|
isCtrl = false;
|
||||||
return FutureBuilder(future: AuthService.init(),
|
if (!AuthService.isConnected()) {
|
||||||
builder: (e, s) {
|
print("isConnected: ${AuthService.isConnected()}");
|
||||||
WorkspaceLocal.init(context, false);
|
|
||||||
CollaborativeAreaLocal.init(context, false);
|
|
||||||
if (!AuthService.isConnected()) {
|
|
||||||
Future.delayed(const Duration(milliseconds: 500), () {
|
Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
showDialog(
|
showDialog(
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@ -105,7 +102,12 @@ class MainPageState extends State<MainPage> {
|
|||||||
title: LoginWidget());
|
title: LoginWidget());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return FutureBuilder(future: AuthService.init(),
|
||||||
|
builder: (e, s) {
|
||||||
|
WorkspaceLocal.init(context, false);
|
||||||
|
CollaborativeAreaLocal.init(context, false);
|
||||||
|
|
||||||
HeaderConstants.height = HeaderConstants.isNoHeader(AppRouter.currentRoute.route) || AppRouter.currentRoute.factory.searchFill() ? 50 : 100;
|
HeaderConstants.height = HeaderConstants.isNoHeader(AppRouter.currentRoute.route) || AppRouter.currentRoute.factory.searchFill() ? 50 : 100;
|
||||||
return Scaffold( key: scaffoldKey, endDrawer: EndDrawerWidget(), body:
|
return Scaffold( key: scaffoldKey, endDrawer: EndDrawerWidget(), body:
|
||||||
SingleChildScrollView(
|
SingleChildScrollView(
|
||||||
|
@ -18,24 +18,23 @@ class LoginWidgetState extends State<LoginWidget> {
|
|||||||
FocusNode focusNode = FocusNode();
|
FocusNode focusNode = FocusNode();
|
||||||
@override Widget build(BuildContext context) {
|
@override Widget build(BuildContext context) {
|
||||||
return KeyboardListener(focusNode: focusNode,
|
return KeyboardListener(focusNode: focusNode,
|
||||||
onKeyEvent: (value) {
|
onKeyEvent: (value) async {
|
||||||
if (value is KeyDownEvent && value.logicalKey == LogicalKeyboardKey.enter) {
|
if (value is KeyDownEvent && value.logicalKey == LogicalKeyboardKey.enter) {
|
||||||
if (usernameCtrl.text == "" || passwordCtrl.text == "") { return; }
|
if (usernameCtrl.text == "" || passwordCtrl.text == "") { return; }
|
||||||
error = null;
|
error = null;
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = true;
|
loading = true;
|
||||||
});
|
});
|
||||||
AuthService.login(usernameCtrl.text, passwordCtrl.text).catchError( (e) {
|
await AuthService.login(usernameCtrl.text, passwordCtrl.text).catchError( (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = false;
|
loading = false;
|
||||||
error = "Invalid username or password";
|
error = "Invalid username or password";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = true;
|
loading = false;
|
||||||
});
|
});
|
||||||
context.pop();
|
context.pop();
|
||||||
}
|
}
|
||||||
@ -114,6 +113,7 @@ class LoginWidgetState extends State<LoginWidget> {
|
|||||||
loading = true;
|
loading = true;
|
||||||
});
|
});
|
||||||
context.pop();
|
context.pop();
|
||||||
|
//mainKey?.currentState!.setState(() {});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mouseCursor: SystemMouseCursors.click,
|
mouseCursor: SystemMouseCursors.click,
|
||||||
|
Loading…
Reference in New Issue
Block a user