adaptation code
This commit is contained in:
parent
05eba7cba2
commit
d439217f1d
@ -39,11 +39,20 @@ class _LoginDemoState extends State<LoginDemo> with ShowErrorDialog {
|
|||||||
var password = inputPassword.text;
|
var password = inputPassword.text;
|
||||||
if ((pseudo.isNotEmpty) && (password.isNotEmpty)) {
|
if ((pseudo.isNotEmpty) && (password.isNotEmpty)) {
|
||||||
try {
|
try {
|
||||||
String credentials = "${pseudo}:${password}";
|
//String credentials = "${pseudo}:${password}";
|
||||||
Codec<String, String> stringToBase64 = utf8.fuse(base64);
|
//Codec<String, String> stringToBase64 = utf8.fuse(base64);
|
||||||
String encoded = stringToBase64.encode(credentials);
|
//String encoded = stringToBase64.encode(credentials);
|
||||||
var response = await http.get(url, headers: {
|
var response = await http.post(url,
|
||||||
HttpHeaders.authorizationHeader: 'Basic $encoded',
|
// headers: {
|
||||||
|
// HttpHeaders.authorizationHeader: 'Basic $encoded',
|
||||||
|
//}
|
||||||
|
headers: {
|
||||||
|
'accept': 'application/json',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
"username": "${pseudo}",
|
||||||
|
"password": "${password}"
|
||||||
});
|
});
|
||||||
|
|
||||||
if ((response.statusCode == 200) || (response.statusCode == 201)) {
|
if ((response.statusCode == 200) || (response.statusCode == 201)) {
|
||||||
@ -54,14 +63,9 @@ class _LoginDemoState extends State<LoginDemo> with ShowErrorDialog {
|
|||||||
var cookiesMany = cookie.split(",");
|
var cookiesMany = cookie.split(",");
|
||||||
for (var cookie2 in cookiesMany) {
|
for (var cookie2 in cookiesMany) {
|
||||||
switch (cookie2.split("=")[0]) {
|
switch (cookie2.split("=")[0]) {
|
||||||
case "jwt":
|
case "access_token":
|
||||||
{
|
{
|
||||||
prefs.setString("jwt", cookie2.toString());
|
prefs.setString("access_token", cookie2.split("=")[1]);
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "user":
|
|
||||||
{
|
|
||||||
prefs.setString("user", cookie2.toString());
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user