diff --git a/covas_mobile/lib/MyHomePage.dart b/covas_mobile/lib/MyHomePage.dart index 08e1f28..eb641e0 100644 --- a/covas_mobile/lib/MyHomePage.dart +++ b/covas_mobile/lib/MyHomePage.dart @@ -62,22 +62,21 @@ class _MyHomePageState extends State with ShowErrorDialog { Future _incrementCounter() async { SharedPreferences prefs = await SharedPreferences.getInstance(); - var user = prefs.getString("user") ?? ""; - var jwt = prefs.getString("jwt") ?? ""; + var accessToken = prefs.getString("access_token") ?? ""; String former = ""; - if ((user.isNotEmpty) && (jwt.isNotEmpty)) { + if (accessToken.isNotEmpty) { var urlGet = Uri.parse("http://${globals.api}/users"); - var responseGet = await http - .get(urlGet, headers: {HttpHeaders.cookieHeader: '${jwt}; ${user}'}); - + var responseGet = await http.get(urlGet, + headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'}); stderr.writeln('Response Get status: ${responseGet.statusCode}'); if (responseGet.statusCode == 200) { - stderr.writeln('Response Get body: ${responseGet.body}'); + stderr.writeln('Username : ${responseGet.body}'); var json = jsonDecode(responseGet.body); for (var user in json) { - former = "$former\n ${user['name']}"; + stderr.writeln('email : ${user['email']}'); + former = "$former\n ${user['email']}"; } } else { var text = ""; diff --git a/covas_mobile/lib/main.dart b/covas_mobile/lib/main.dart index 20973ee..63d637f 100644 --- a/covas_mobile/lib/main.dart +++ b/covas_mobile/lib/main.dart @@ -128,21 +128,19 @@ class _LoginDemoState extends State 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 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(