Skip to content

fix(learnocaml_common.ml): change secret to token for authentificatio… #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/app/learnocaml_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1106,17 +1106,23 @@ let get_token ?(has_server = true) () =
try
Some Learnocaml_local_storage.(retrieve sync_token) |>
Lwt.return
with Not_found ->
with
Not_found ->
retrieve (Learnocaml_api.Nonce ())
>>= fun nonce ->
ask_string ~title:"Secret"
[H.txt [%i"Enter the secret"]]
>>= fun secret ->
retrieve
(Learnocaml_api.Create_token (Sha.sha512 (nonce ^ Sha.sha512 secret), None, None))
>|= fun token ->
Learnocaml_local_storage.(store sync_token) token;
Some token
ask_string ~title:"Token"
[H.txt [%i"Enter your token"]]
>>= fun input_tok ->
let token = Token.parse (input_tok) in
Server_caller.request (Learnocaml_api.Fetch_save token)
>>= function
| Ok save ->
set_state_from_save_file ~token save;
Lwt.return_some token
| _ ->
alert ~title:[%i"TOKEN NOT FOUND"]
[%i"The entered token couldn't be recognised."];
Lwt.return_none

module Display_exercise =
functor (
Expand Down
2 changes: 1 addition & 1 deletion src/app/learnocaml_common.mli
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ val setup_tab_text_prelude_pane : string -> unit

val setup_prelude_pane : 'a Ace.editor -> string -> unit

val get_token : ?has_server:bool -> unit -> Learnocaml_data.student Learnocaml_data.token option Lwt.t
val get_token : ?has_server:bool -> unit -> Learnocaml_data.Token.t option Lwt.t

module Display_exercise :functor
(_ : sig
Expand Down