]> jfr.im git - irc/quakenet/newserv.git/blobdiff - auth/auth.c
Update README.
[irc/quakenet/newserv.git] / auth / auth.c
index af7920ef05bcaa7905b46da802ba750ea5c2e1e0..4885205a724223c025279ce529fca81693bd0308 100644 (file)
@@ -4,33 +4,50 @@
 #include "../nick/nick.h"
 #include "../irc/irc.h"
 #include "../localuser/localuser.h"
+#include "../lib/flags.h"
+#include "../lib/version.h"
 
+MODULE_VERSION("");
+
+/* we allow reauthing for flag changing, as well as testing purposes */
 int au_auth(void *source, int cargc, char **cargv) {
   nick *sender=(nick *)source;
-  char *authname, *dummy;
+  char *authname;
+  int authts;
   int authid;
+  flag_t flags;
 
   if(cargc < 2)
     return CMD_USAGE;
 
-  if(sscanf(myserver->content, "%s.quakenet.org", dummy) == 1) {
+  if(sscanf(myserver->content, "%*s.quakenet.org") == 1) {
     controlreply(sender, "Sorry, you can't use this command on QuakeNet.");
     return CMD_ERROR;
   }
 
+  if(cargc > 3) {
+    if(setflags(&flags, AFLAG_ALL, cargv[3], accountflags, REJECT_UNKNOWN) != REJECT_NONE) {
+      controlreply(sender, "Bad flag(s) supplied.");
+      return CMD_ERROR;
+    }
+  } else {
+    flags = 0;
+  }
+
   authname = cargv[0];
-  authid = atoi(cargv[1]);
+  authts = atoi(cargv[1]);
+  authid = atoi(cargv[2]);
 
-  controlwall(NO_OPER, NL_OPERATIONS, "AUTH'ed at %s:%d", authname, authid);
+  controlwall(NO_OPER, NL_OPERATIONS, "AUTH'ed at %s:%d:%d:%s", authname, authts, authid, printflags(flags, accountflags));
 
-  localusersetaccount(sender, authname, authid, 0, 0);
+  localusersetaccount(sender, authname, authid, flags, authts);
   controlreply(sender, "Done.");
 
   return CMD_OK;
 }
 
 void _init() {
-  registercontrolhelpcmd("auth", NO_OPER, 1, au_auth, "Usage: auth <authname> <authid>");
+  registercontrolhelpcmd("auth", NO_OPERED, 3, au_auth, "Usage: auth <authname> <authts> <authid> ?accountflags?");
 }
 
 void _fini() {