]>
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; |
26295e70 | 16 | int authts; |
7b1bf975 | 17 | int authid; |
5a7117e4 | 18 | flag_t flags; |
7b1bf975 CP |
19 | |
20 | if(cargc < 2) | |
21 | return CMD_USAGE; | |
22 | ||
5a7117e4 | 23 | if(sscanf(myserver->content, "%*s.quakenet.org") == 1) { |
7b1bf975 CP |
24 | controlreply(sender, "Sorry, you can't use this command on QuakeNet."); |
25 | return CMD_ERROR; | |
26 | } | |
27 | ||
26295e70 | 28 | if(cargc > 3) { |
29 | if(setflags(&flags, AFLAG_ALL, cargv[3], accountflags, REJECT_UNKNOWN) != REJECT_NONE) { | |
5a7117e4 CP |
30 | controlreply(sender, "Bad flag(s) supplied."); |
31 | return CMD_ERROR; | |
32 | } | |
33 | } else { | |
34 | flags = 0; | |
35 | } | |
36 | ||
7b1bf975 | 37 | authname = cargv[0]; |
26295e70 | 38 | authts = atoi(cargv[1]); |
39 | authid = atoi(cargv[2]); | |
7b1bf975 | 40 | |
26295e70 | 41 | controlwall(NO_OPER, NL_OPERATIONS, "AUTH'ed at %s:%d:%d:%s", authname, authts, authid, printflags(flags, accountflags)); |
7b1bf975 | 42 | |
26295e70 | 43 | localusersetaccount(sender, authname, authid, flags, authts); |
7b1bf975 CP |
44 | controlreply(sender, "Done."); |
45 | ||
46 | return CMD_OK; | |
47 | } | |
48 | ||
49 | void _init() { | |
26295e70 | 50 | registercontrolhelpcmd("auth", NO_OPERED, 3, au_auth, "Usage: auth <authname> <authts> <authid> ?accountflags?"); |
7b1bf975 CP |
51 | } |
52 | ||
53 | void _fini() { | |
54 | deregistercontrolcmd("auth", au_auth); | |
55 | } | |
56 |