From c4b570e8fd9803b1058240c62604e03610b26bb3 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Tue, 9 Feb 2016 18:06:13 +0100 Subject: [PATCH] new menus for account management During startup, it is checked, if the game account needs to be unlocked by password. If so, the password is asked and applied. If no game account exists yet, the creation of a new account is offered. new command "mypubkey": returns public key of game account, or empty string, if no account exists or it is unusable (due to missing password, for example) DOCREF mypubkey --- config/autostart/checkaccount.cfg | 5 +++++ config/autostart/welcome.cfg | 2 +- config/menus_settings.cfg | 37 +++++++++++++++++++++++++++++++ source/src/crypto.cpp | 9 ++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 config/autostart/checkaccount.cfg diff --git a/config/autostart/checkaccount.cfg b/config/autostart/checkaccount.cfg new file mode 100644 index 00000000..6c39634f --- /dev/null +++ b/config/autostart/checkaccount.cfg @@ -0,0 +1,5 @@ +// check account during startup +// * ask for password, if required +// * offer to create new account, if none exists + +sleep 1000 checkaccount 1 diff --git a/config/autostart/welcome.cfg b/config/autostart/welcome.cfg index eff3d5f8..64fd89ec 100644 --- a/config/autostart/welcome.cfg +++ b/config/autostart/welcome.cfg @@ -1,6 +1,6 @@ // show main menu on startup, if enabled if $showmenuonstartup [ - sleep 1000 [ showmenu main ] 1 + sleep 2000 [ if (strlen (curmenu)) [] [showmenu main ] ] 1 ] diff --git a/config/menus_settings.cfg b/config/menus_settings.cfg index 481cd47b..af8d0e04 100644 --- a/config/menus_settings.cfg +++ b/config/menus_settings.cfg @@ -836,5 +836,42 @@ menuinit [ ] ] +// game account management menus + +newmenu "enter password" +menuitemtextinput "please enter the password for your game account\t" "" [ echo "checking..." ; authsetup passd $arg1 checkaccount ] [] 64 1 + +newmenu "offer account" +menuitem "To create a game account, AC needs some entropy. To generate" -1 +menuitem "that, you need to play against bots for 10 minutes first..." -1 +menuitem "" -1 +menuitem "\t\t\f0[Start]" [tmp_mode = 8; tmp_isbotteammode = 0; tmp_numbots = (+ 7 (rnd 4)) ; tmp_botmap = (at "ac_scaffold ac_desert2 ac_complex" (rnd 3)); sleep 605000 __createaccount 1 ; startbotmap] +menuitem "\t\t[Not now...]" closemenu + +tempalias __createaccount [ + disconnect + kickallbots + showmenu "create account" +] + +newmenu "create account" +menuinit [ authsetup genpre; authsetup genpriv; authsetup genpub; echo "\f4temp account created." ; tempalias ___ppass "" ; tempalias ___pass "" ] +menuitemtextinput "please enter a password for account restoration\t" "" [___ppass = $arg1] [] 64 +menuitemtextinput "please enter a password for your game account\t" "" [___pass = $arg1] [] 64 +menuitem "" -1 +menuitem "\t\t\f0[Ok]" [ authsetup newppass $___ppass ; authsetup newpass $___pass ; ___ppass = "" ; ___pass = "" ; if (authsetup) [ echo "created account" (mypubkey)] checkaccount ] + +const checkaccount [ + if (authsetup) [ + echo "\f0using account " (mypubkey) + ] [ + if (authsetup needpass) [] [ exec config/authprivate.cfg ] + if (authsetup needpass) [ + showmenu "enter password" + ] [ + showmenu "offer account" + ] + ] +] persistidents 1 diff --git a/source/src/crypto.cpp b/source/src/crypto.cpp index ffa66b04..b9d0f584 100644 --- a/source/src/crypto.cpp +++ b/source/src/crypto.cpp @@ -880,6 +880,15 @@ void authsetup(char **args, int numargs) // set up private and public keys } COMMAND(authsetup, "v"); +void mypubkey() +{ + string res = ""; + if(sk) bin2hex(res, sk + 32, 32); + result(res); +} +COMMAND(mypubkey, ""); + + ///////////////////////////////////////////////// misc key management ////////////////////////////////////////////////////// // * used to sign certs or other stuff // * dev/admin/master keys