preparation for 2fa
This commit is contained in:
parent
85c20935c0
commit
4a2db80c54
4 changed files with 15 additions and 5 deletions
|
@ -22,7 +22,7 @@ $ opam switch list
|
|||
```
|
||||
|
||||
```sh
|
||||
$ opam install cohttp-lwt-unix tls-lwt dotenv
|
||||
$ opam install cohttp-lwt-unix tls-lwt dotenv twostep
|
||||
```
|
||||
|
||||
## Name history
|
||||
|
|
2
bin/dune
2
bin/dune
|
@ -2,4 +2,4 @@
|
|||
(public_name pusk)
|
||||
(name main)
|
||||
(modules main twitter)
|
||||
(libraries pusk))
|
||||
(libraries pusk twostep))
|
||||
|
|
|
@ -25,7 +25,7 @@ let main ctx =
|
|||
| None, Some _ -> raise (Any "Username not set")
|
||||
| Some _, None -> raise (Any "Password not set")
|
||||
in
|
||||
login_twitter ctx username password
|
||||
login_twitter ctx username password (Sys.getenv_opt "TWITTER_TOTP")
|
||||
;;
|
||||
|
||||
let () =
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
open Pusk.Net
|
||||
open Pusk.Utils
|
||||
(* open Twostep *)
|
||||
|
||||
let login_twitter ctx username password =
|
||||
let login_twitter ctx username password _secret =
|
||||
(* Navigate to login page and wait for page loaded*)
|
||||
ignore (navigate ctx.session_id "https://twitter.com/i/flow/login");
|
||||
Unix.sleep 5;
|
||||
|
@ -42,5 +43,14 @@ let login_twitter ctx username password =
|
|||
send_keys ctx.session_id input_password password;
|
||||
Unix.sleep 1;
|
||||
send_keys ctx.session_id input_password Keys.return;
|
||||
Unix.sleep 5
|
||||
Unix.sleep 5;
|
||||
(* Detection of 2FA *)
|
||||
(* TODO *)
|
||||
(* Generate code if possible *)
|
||||
(* let code =
|
||||
match secret with
|
||||
| Some seed -> Twostep.TOTP.code ~secret:seed ()
|
||||
| None -> raise (Any "No TOTP code given, but TOTP required")
|
||||
in *)
|
||||
()
|
||||
;;
|
||||
|
|
Loading…
Reference in a new issue