]> skyeroc.xyz Git - dgamelaunch/commitdiff
Add account flags for admins, banned accounts, preventing password or email changing.
authorPasi Kallinen <paxed@alt.org>
Sat, 29 Jan 2011 16:39:05 +0000 (16:39 +0000)
committerPasi Kallinen <paxed@alt.org>
Sat, 29 Jan 2011 16:39:05 +0000 (16:39 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@581 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

TODO
dgamelaunch.c
dgamelaunch.h
dgl-common.c

diff --git a/TODO b/TODO
index 3fc384b0b01a8586e9e991e659f5bdf5de2b4047..b5e0d4a1a68170f86fa9675b7a40d62511f64add 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,4 @@
 
--remove editoptions() and the editor compiled into dgl.
-
 -move the games[] array into shmem?
 
 -$MTIME(filename)
@@ -32,8 +30,6 @@
  key not defined in other commands):
    commands[default] = ...
 
--in watching-menu, maybe we shouldn't pick players who have been
- idle for too long when randomly choosing one to watch.
 -change dgl-banner handling; we only use the top line of it nowadays...
  (maybe make that info config line: bannerline = "## $SERVERID" or something)
 -allow the admin to config the watching menu:
index d0190ab14766eea08f065853775d312a959a7ef3..24f8414594f5b17d56206c9996a2855233821f24 100644 (file)
@@ -208,6 +208,17 @@ signals_release()
 
 /* ************************************************************* */
 
+char *
+get_mainmenu_name()
+{
+    if (loggedin) {
+       if (me && (me->flags & DGLACCT_ADMIN)) return "mainmenu_admin";
+       return "mainmenu_user";
+    }
+    return "mainmenu_anon";
+}
+
+
 char*
 gen_ttyrec_filename ()
 {
@@ -1089,6 +1100,13 @@ change_email ()
 
   clear();
 
+  if (me->flags & DGLACCT_EMAIL_LOCK) {
+      drawbanner(&banner, 1, 1);
+      mvprintw(5, 1, "Sorry, you cannot change the email.--More--");
+      dgl_getch();
+      return;
+  }
+
   for (;;)
   {
       drawbanner(&banner, 1,1);
@@ -1146,6 +1164,14 @@ changepw (int dowrite)
     graceful_exit (122);        /* Die. */
   }
 
+  if (me->flags & DGLACCT_PASSWD_LOCK) {
+      clear();
+      drawbanner(&banner, 1, 1);
+      mvprintw(5, 1, "Sorry, you cannot change the password.--More--");
+      dgl_getch();
+      return 0;
+  }
+
   while (error)
     {
       char repeatbuf[DGL_PASSWDLEN+1];
@@ -1420,7 +1446,7 @@ autologin (char* user, char *pass)
   tmp = userexist(user, 0);
   if (tmp) {
       me = cpy_me(tmp);
-      if (passwordgood(pass)) {
+      if (passwordgood(pass) && !(me->flags & DGLACCT_LOGIN_LOCK)) {
          loggedin = 1;
          setproctitle ("%s", me->username);
          dgl_exec_cmdqueue(globalconfig.cmdqueue[DGLTIME_LOGIN], 0, me);
@@ -1488,6 +1514,13 @@ loginprompt (int from_ttyplay)
 
   if (passwordgood (pw_buf))
     {
+       if (me->flags & DGLACCT_LOGIN_LOCK) {
+           clear ();
+           mvprintw(5, 1, "Sorry, that account has been banned.--More--");
+           dgl_getch();
+           return;
+       }
+
       loggedin = 1;
       if (from_ttyplay)
          setproctitle("%s [watching %s]", me->username, chosen_name);
@@ -1651,6 +1684,7 @@ newuser ()
 
   me->email = strdup (buf);
   me->env = calloc (1, 1);
+  me->flags = 0;
 
   loggedin = 1;
 
@@ -2507,7 +2541,7 @@ main (int argc, char** argv)
   idle_alarm_set_enabled(1);
 
   while (1) {
-      if (runmenuloop(dgl_find_menu(loggedin ? "mainmenu_user" : "mainmenu_anon")))
+      if (runmenuloop(dgl_find_menu(get_mainmenu_name())))
          break;
   }
 
index b81687d0bd901a7c10f00e75160f9498a7411f37..8932b6e4ddd1bf47124c66a4f86fab835a7c4883 100644 (file)
 # define CLR_RED     0
 #endif
 
+typedef enum
+{
+    DGLACCT_ADMIN       = 0x01,        /* admin account */
+    DGLACCT_LOGIN_LOCK  = 0x02,        /* account is banned and cannot login */
+    DGLACCT_PASSWD_LOCK = 0x04,        /* account password cannot be changed */
+    DGLACCT_EMAIL_LOCK  = 0x08 /* account email cannot be changed */
+} dgl_acct_flag;
+
 typedef enum
 {
     DGLTIME_DGLSTART = 0,      /* when someone telnets in */
@@ -58,7 +66,7 @@ struct dg_user
   char *email;
   char *env;
   char *password;
-  int flags;
+  int flags;                   /* dgl_acct_flag bitmask */
 };
 
 struct dg_banner
@@ -231,6 +239,7 @@ extern int dgl_local_LINES;
 /* dgamelaunch.c */
 extern void create_config(void);
 extern void ttyrec_getmaster(void);
+extern char *get_mainmenu_name(void);
 extern char *gen_ttyrec_filename(void);
 extern char *gen_inprogress_lock(int game, pid_t pid, char *ttyrec_filename);
 extern void catch_sighup(int signum);
index 95050de1f562d00ec18b00d82868dbece4dc45ee..3e5f6f45b3710ee292ae109ceb89e20b316add72 100644 (file)
@@ -302,7 +302,7 @@ dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me)
            break;
        case DGLCMD_LOGIN:
            if (!loggedin) loginprompt(0);
-           if (loggedin) runmenuloop(dgl_find_menu("mainmenu_user"));
+           if (loggedin) runmenuloop(dgl_find_menu(get_mainmenu_name()));
            break;
        case DGLCMD_REGISTER:
            if (!loggedin && globalconfig.allow_registration) newuser();