Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final response = await HttpRequest.get(loginUrl);
- if (!response.isSuccess) return LoginResult(LoginResultType.NETWORK_ERROR);
- final document = parse(response.httpResponse.body);
- // Extract lt value from HTML
- final ltInput = document.querySelector('input[name="lt"]');
- String lt = "";
- if (ltInput?.attributes?.containsKey("value") ?? false)
- lt = ltInput.attributes['value'];
- final executionInput = document.querySelector('input[name="execution"]');
- String execution = "e1s1";
- if (executionInput?.attributes?.containsKey("value") ?? false)
- execution = executionInput.attributes['value'];
- // POST data
- Map<String, String> postParams = {
- "_eventId": "submit",
- "lt": lt,
- "submit": "LOGIN",
- "username": username,
- "password": password,
- "execution": execution,
- };
- // Get JSESSIONID from previous request header
- final cookie = response.httpResponse.headers["set-cookie"];
- // Second request, with all necessary data
- final loginResponse = await HttpRequest.post(
- loginUrl,
- body: postParams,
- headers: {"cookie": cookie},
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement