start functions with response token wip
This commit is contained in:
parent
2aeacb034b
commit
1fd6e56208
@ -122,7 +122,22 @@ class _LoginDemoState extends State<LoginDemo> with ShowErrorDialog {
|
|||||||
|
|
||||||
void start() async {
|
void start() async {
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
stderr.writeln(prefs.getString("jwt"));
|
var jwt = prefs.getString("jwt") ?? "";
|
||||||
|
var user = prefs.getString("user") ?? "";
|
||||||
|
stderr.writeln(jwt);
|
||||||
|
if ((jwt.isNotEmpty) && (user.isNotEmpty)) {
|
||||||
|
var urlToken = Uri.parse("http://localhost:8083/api/token");
|
||||||
|
|
||||||
|
var responseToken = await http.get(urlToken,
|
||||||
|
headers: {HttpHeaders.cookieHeader: '${jwt}; ${user}'});
|
||||||
|
stderr.writeln(responseToken.statusCode);
|
||||||
|
if (responseToken.statusCode == 200) {
|
||||||
|
MaterialPageRoute(builder: (_) => MyHomePage(title: 'Flutter Demo'));
|
||||||
|
} else {
|
||||||
|
prefs.remove("jwt");
|
||||||
|
prefs.remove("user");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user