]>
Commit | Line | Data |
---|---|---|
7b1bf975 CP |
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" | |
5a7117e4 | 7 | #include "../lib/flags.h" |
7b1bf975 | 8 | |
5a7117e4 | 9 | /* we allow reauthing for flag changing, as well as testing purposes */ |
7b1bf975 CP |
10 | int au_auth(void *source, int cargc, char **cargv) { |
11 | nick *sender=(nick *)source; | |
5a7117e4 | 12 | char *authname; |
7b1bf975 | 13 | int authid; |
5a7117e4 | 14 | flag_t flags; |
7b1bf975 CP |
15 | |
16 | if(cargc < 2) | |
17 | return CMD_USAGE; | |
18 | ||
5a7117e4 | 19 | if(sscanf(myserver->content, "%*s.quakenet.org") == 1) { |
7b1bf975 CP |
20 | controlreply(sender, "Sorry, you can't use this command on QuakeNet."); |
21 | return CMD_ERROR; | |
22 | } | |
23 | ||
5a7117e4 CP |
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 | ||
7b1bf975 CP |
33 | authname = cargv[0]; |
34 | authid = atoi(cargv[1]); | |
35 | ||
5a7117e4 | 36 | controlwall(NO_OPER, NL_OPERATIONS, "AUTH'ed at %s:%d:%s", authname, authid, printflags(flags, accountflags)); |
7b1bf975 | 37 | |
5a7117e4 | 38 | localusersetaccount(sender, authname, authid, flags, 0); |
7b1bf975 CP |
39 | controlreply(sender, "Done."); |
40 | ||
41 | return CMD_OK; | |
42 | } | |
43 | ||
44 | void _init() { | |
305cf170 | 45 | registercontrolhelpcmd("auth", NO_OPERED, 3, au_auth, "Usage: auth <authname> <authid> ?accountflags?"); |
7b1bf975 CP |
46 | } |
47 | ||
48 | void _fini() { | |
49 | deregistercontrolcmd("auth", au_auth); | |
50 | } | |
51 |