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