]> jfr.im git - irc/quakenet/newserv.git/blob - auth/auth.c
NICK: Add "away" functionality.
[irc/quakenet/newserv.git] / auth / auth.c
1 #include <stdio.h>
2
3 #include "../control/control.h"
4 #include "../nick/nick.h"
5 #include "../irc/irc.h"
6 #include "../localuser/localuser.h"
7 #include "../lib/flags.h"
8
9 /* we allow reauthing for flag changing, as well as testing purposes */
10 int au_auth(void *source, int cargc, char **cargv) {
11 nick *sender=(nick *)source;
12 char *authname;
13 int authid;
14 flag_t flags;
15
16 if(cargc < 2)
17 return CMD_USAGE;
18
19 if(sscanf(myserver->content, "%*s.quakenet.org") == 1) {
20 controlreply(sender, "Sorry, you can't use this command on QuakeNet.");
21 return CMD_ERROR;
22 }
23
24 if(cargc > 2) {
25 if(setflags(&flags, AFLAG_ALL, cargv[2], accountflags, REJECT_UNKNOWN) != REJECT_NONE) {
26 controlreply(sender, "Bad flag(s) supplied.");
27 return CMD_ERROR;
28 }
29 } else {
30 flags = 0;
31 }
32
33 authname = cargv[0];
34 authid = atoi(cargv[1]);
35
36 controlwall(NO_OPER, NL_OPERATIONS, "AUTH'ed at %s:%d:%s", authname, authid, printflags(flags, accountflags));
37
38 localusersetaccount(sender, authname, authid, flags, 0);
39 controlreply(sender, "Done.");
40
41 return CMD_OK;
42 }
43
44 void _init() {
45 registercontrolhelpcmd("auth", NO_OPERED, 3, au_auth, "Usage: auth <authname> <authid> ?accountflags?");
46 }
47
48 void _fini() {
49 deregistercontrolcmd("auth", au_auth);
50 }
51