oauth2 state of mind
This commit is contained in:
@@ -2,12 +2,14 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/services/auth.service.dart';
|
||||
import 'package:oc_front/core/services/oauth2.service.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/pages/workflow.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class LoginWidget extends StatefulWidget {
|
||||
LoginWidget ({ Key? key }): super(key: key);
|
||||
String? loginChallenge;
|
||||
LoginWidget ({ super.key, required this.loginChallenge });
|
||||
@override LoginWidgetState createState() => LoginWidgetState();
|
||||
}
|
||||
class LoginWidgetState extends State<LoginWidget> {
|
||||
@@ -18,7 +20,8 @@ class LoginWidgetState extends State<LoginWidget> {
|
||||
bool loading = false;
|
||||
FocusNode focusNode = FocusNode();
|
||||
@override Widget build(BuildContext context) {
|
||||
return KeyboardListener(focusNode: focusNode,
|
||||
return KeyboardListener(
|
||||
focusNode: focusNode,
|
||||
onKeyEvent: (value) async {
|
||||
if (value is KeyDownEvent && value.logicalKey == LogicalKeyboardKey.enter) {
|
||||
if (usernameCtrl.text == "" || passwordCtrl.text == "") { return; }
|
||||
@@ -26,7 +29,7 @@ class LoginWidgetState extends State<LoginWidget> {
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
await AuthService.login(usernameCtrl.text, passwordCtrl.text).catchError( (e) {
|
||||
await OAuth2Service().login(usernameCtrl.text, passwordCtrl.text, widget.loginChallenge ?? '').catchError( (e) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
error = "Invalid username or password";
|
||||
@@ -47,8 +50,8 @@ class LoginWidgetState extends State<LoginWidget> {
|
||||
},
|
||||
child: Container( padding: const EdgeInsets.all(50), child: Column(children: [
|
||||
getMainHeight(context) < 600 ? Container() : SizedBox( width: getMainWidth(context) / 4, height: getMainHeight(context) / 4,
|
||||
child: FittedBox(
|
||||
child:const Center(child: Icon(Icons.person_search, size: 150, color: Colors.grey,)))),
|
||||
child: const FittedBox(
|
||||
child:Center(child: Icon(Icons.person_search, size: 150, color: Colors.grey,)))),
|
||||
Center(child: Padding( padding: const EdgeInsets.only(top: 5, bottom: 20),
|
||||
child: Text("WELCOME ON OPENCLOUD", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600,
|
||||
color: lightColor ), overflow: TextOverflow.ellipsis, ))),
|
||||
@@ -107,7 +110,7 @@ class LoginWidgetState extends State<LoginWidget> {
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
await AuthService.login(usernameCtrl.text, passwordCtrl.text).catchError( (e) {
|
||||
await OAuth2Service().login(usernameCtrl.text, passwordCtrl.text, widget.loginChallenge ?? '').catchError( (e) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
error = "Invalid username or password";
|
||||
|
||||
Reference in New Issue
Block a user