login method
Implementation
Future<bool> login() async {
bool result = false;
if (_userid != '' && _pwd != '') {
var url = preset.serverURL! +
preset.rootAccountId! +
'/' +
preset.apiURL! +
'?suba=' +
_suba +
'&mode=signin'; //"http://springroll.operahouse.systems/raifitbdg/ophcore/api/default.aspx?mode=signin";
print(url);
Map<String, String> body = {'userid': _userid, 'pwd': _pwd};
String value = await httpSvc.getXML(url, body: body);
XmlDocument xmlDoc = XmlDocument.parse(value);
var _h =
xmlDoc.findAllElements("hostGUID").map((node) => node.text).toList();
var _u =
xmlDoc.findAllElements("userGUID").map((node) => node.text).toList();
var _un =
xmlDoc.findAllElements("userName").map((node) => node.text).toList();
var _up = xmlDoc
.findAllElements("profileImage")
.map((node) => node.text)
.toList();
if (_h.length > 0) {
//await httpSvc.loadAccount('login', hostguid: preset.hostguid);
preset.hostguid = _h[0];
preset.accountId = _suba;
//preset.curState = {};
if (_un.length > 0) preset.curState['userName'] = _un[0];
if (_up.length > 0) preset.curState['userURL'] = _up[0];
print(preset.hostguid);
result = true;
} else {
var _m =
xmlDoc.findAllElements("message").map((node) => node.text).toList();
if (_m.length > 0) _msg = _m[0];
print(_msg);
}
if (_u.length > 0) {
preset.userguid = _u[0];
}
}
return result;
}