This commit is contained in:
2024-06-23 14:28:03 +02:00
parent d439217f1d
commit dac570fffc
2 changed files with 16 additions and 18 deletions

View File

@@ -128,21 +128,19 @@ class _LoginDemoState extends State<LoginDemo> with ShowErrorDialog {
void start() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
var jwt = prefs.getString("jwt") ?? "";
var user = prefs.getString("user") ?? "";
if ((jwt.isNotEmpty) && (user.isNotEmpty)) {
var access_token = prefs.getString("access_token") ?? "";
if (access_token.isNotEmpty) {
var urlToken = Uri.parse("https://${globals.api}/token");
var responseToken = await http.get(urlToken,
headers: {HttpHeaders.cookieHeader: '${jwt}; ${user}'});
headers: {HttpHeaders.cookieHeader: 'access_token: ${access_token}'});
if (responseToken.statusCode == 200) {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => MyHomePage(title: 'Flutter Demo')));
} else {
prefs.remove("jwt");
prefs.remove("user");
prefs.remove("access_token");
}
}
}
@@ -167,12 +165,13 @@ class _LoginDemoState extends State<LoginDemo> with ShowErrorDialog {
padding: const EdgeInsets.only(top: 60.0),
child: Center(
child: Container(
width: 200,
height: 150,
/*decoration: BoxDecoration(
width: 200,
height: 150,
/*decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(50.0)),*/
child: Image.asset('asset/images/flutter-logo.png')),
//child: Image.asset('asset/images/flutter-logo.png')
),
),
),
Padding(