login static method
Implementation
static Future<LoginSession> login({
required UserIdentifier identifier,
required String password,
}) async {
HeraRequest req = HeraRequest()..namespace = _namespace;
User user = userWithIdentifiers(identifier);
req.user = user;
user.password = Hash(body: password);
// analytical information about token
Token _token = Token();
_token.deviceInfo = await HeraExtenstion.getDeviceInfo();
req.token = _token;
try {
HeraResponse resp = await _heraClient.login(req);
if (resp.loginSession.loginStatus != LoginStatus.AUTHENTICATED) {
return resp.loginSession;
}
if (resp.token.accessToken == "" || resp.token.refreshToken == "") {
throw Exception("token is null. Contact info@nuntio.io");
}
if (resp.user.id == "") {
throw Exception("user is null. Contact info@nuntio.io");
}
_setCurrentUser(resp.user);
_setAccessToken(resp.token.accessToken);
_setRefreshToken(resp.token.refreshToken);
} catch (e) {
if (_debug == true) print("could not login user: " + e.toString());
rethrow;
}
return LoginSession()..loginStatus = LoginStatus.AUTHENTICATED;
}