login method
Implementation
Future<bool> login(String companyId, int userId, String password) async {
this.userId = userId;
this.password = password;
this.companyId = companyId;
http.Response response = await http.post(Uri.parse(_loginAddress),
body:
'empresa=$companyId&origin=portal&matricula=$userId&senha=$password',
headers: _headers);
if (response.body.isNotEmpty) {
Map<String, dynamic> body = json.decode(response.body);
if (body['r'] == 'success') {
jwt = body['jwt'];
try {
_parseJwtExpirationDate(response.headers['set-cookie']!);
} catch (_) {
return false;
}
return true;
}
}
return false;
}