Add account flags for admins, banned accounts, preventing password or email changing.
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@581 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
643bebe6ab
commit
7223417d76
4
TODO
4
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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,14 @@
|
|||
# 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);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue