verifyCredentials method
Implementation
Future<bool> verifyCredentials(String username, String password) async {
try {
if (username.isEmpty) throw new Exception("Invalid Username");
if (password.isEmpty) throw new Exception("Invalid Password");
var key = base64.encode(utf8.encode("$username:$password"));
var req = await http
.get(Uri.parse(loginUrl), headers: {"Authorization": "Basic $key"});
var success = req.statusCode >= 200 && req.statusCode < 300;
if (!success) return false;
foundAuthCode(key);
return true;
} catch (e) {
return false;
}
}