File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -1106,17 +1106,23 @@ let get_token ?(has_server = true) () =
11061106 try
11071107 Some Learnocaml_local_storage. (retrieve sync_token) |>
11081108 Lwt. return
1109- with Not_found ->
1109+ with
1110+ Not_found ->
11101111 retrieve (Learnocaml_api. Nonce () )
11111112 >> = fun nonce ->
1112- ask_string ~title: " Secret"
1113- [H. txt [% i" Enter the secret" ]]
1114- >> = fun secret ->
1115- retrieve
1116- (Learnocaml_api. Create_token (Sha. sha512 (nonce ^ Sha. sha512 secret), None , None ))
1117- > |= fun token ->
1118- Learnocaml_local_storage. (store sync_token) token;
1119- Some token
1113+ ask_string ~title: " Token"
1114+ [H. txt [% i" Enter your token" ]]
1115+ >> = fun input_tok ->
1116+ let token = Token. parse (input_tok) in
1117+ Server_caller. request (Learnocaml_api. Fetch_save token)
1118+ >> = function
1119+ | Ok save ->
1120+ set_state_from_save_file ~token save;
1121+ Lwt. return_some token
1122+ | _ ->
1123+ alert ~title: [% i" TOKEN NOT FOUND" ]
1124+ [% i" The entered token couldn't be recognised." ];
1125+ Lwt. return_none
11201126
11211127module Display_exercise =
11221128 functor (
Original file line number Diff line number Diff line change @@ -232,7 +232,7 @@ val setup_tab_text_prelude_pane : string -> unit
232232
233233val setup_prelude_pane : 'a Ace .editor -> string -> unit
234234
235- val get_token : ?has_server : bool -> unit -> Learnocaml_data .student Learnocaml_data .token option Lwt .t
235+ val get_token : ?has_server : bool -> unit -> Learnocaml_data.Token .t option Lwt .t
236236
237237module Display_exercise :functor
238238 (_ : sig
You can’t perform that action at this time.
0 commit comments