* Allow users to authenticate with either their display name or any valid
authorArt Cancro <ajc@citadel.org>
Wed, 30 Jul 2003 20:36:18 +0000 (20:36 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 30 Jul 2003 20:36:18 +0000 (20:36 +0000)
  e-mail address which belongs to them.  Applies to all protocols.

citadel/ChangeLog
citadel/support.c
citadel/user_ops.c

index 6180768927864a2e7e995fd4cbb69f74fc73849c..2bbe7eada22cd6e727a9b3974e305daeebf35899 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 608.15  2003/07/30 20:36:18  ajc
+ * Allow users to authenticate with either their display name or any valid
+   e-mail address which belongs to them.  Applies to all protocols.
+
  Revision 608.14  2003/07/30 03:54:34  ajc
  * Fixed a small client bug in the purge hour setting
 
@@ -4927,4 +4931,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index f7f17f7f84e2c155ec96972b6ba304cb956abb4c..970a215fd8ccb7dbb02708a7b19a15f64c53f83b 100644 (file)
@@ -36,7 +36,7 @@ void strproc(char *string)
        for (a=0; a<strlen(string); ++a) {
                if (string[a]<32) string[a]=32;
                if (string[a]>126) string[a]=32;
-               }
+       }
 
        /* Remove leading and trailing blanks */
        while( (string[0]<33) && (strlen(string)>0) )
@@ -49,8 +49,8 @@ void strproc(char *string)
                if ((string[a]==32)&&(string[a+1]==32)) {
                        strcpy(&string[a],&string[a+1]);
                        a=0;
-                       }
                }
+       }
 
        /* remove characters which would interfere with the network */
        for (a=0; a<strlen(string); ++a) {
@@ -60,10 +60,10 @@ void strproc(char *string)
                while (string[a]==',') strcpy(&string[a],&string[a+1]);
                while (string[a]=='%') strcpy(&string[a],&string[a+1]);
                while (string[a]=='|') strcpy(&string[a],&string[a+1]);
-               }
-
        }
 
+}
+
 
 
 /*
index f2ffcf884253a9aa8f8916220ad9b1665ce74360..5934a4ab6b8e28211fced578c50de248d7994066 100644 (file)
@@ -352,6 +352,7 @@ int CtdlLoginExistingUser(char *trythisname)
 {
        char username[SIZ];
        int found_user;
+       struct recptypes *valid = NULL;
 
        if (trythisname == NULL) return login_not_found;
        safestrncpy(username, trythisname, sizeof username);
@@ -361,8 +362,24 @@ int CtdlLoginExistingUser(char *trythisname)
                return login_already_logged_in;
        }
 
+       /* First, try to log in as if the supplied name is a display name */
        found_user = getuser(&CC->user, username);
 
+       /* If that didn't work, try to log in as if the supplied name
+        * is an e-mail address
+        */
+       if (found_user != 0) {
+               valid = validate_recipients(trythisname);
+               if (valid != NULL) {
+                       if (valid->num_local == 1) {
+                               found_user = getuser(&CC->user,
+                                               valid->recp_local);
+                       }
+                       phree(valid);
+               }
+       }
+
+       /* Did we find something? */
        if (found_user == 0) {
                if (((CC->nologin)) && (CC->user.axlevel < 6)) {
                        return login_too_many_users;
@@ -386,8 +403,7 @@ void cmd_user(char *cmdbuf)
        int a;
 
        extract(username, cmdbuf, 0);
-       username[25] = 0;
-       strproc(username);
+       striplt(username);
 
        a = CtdlLoginExistingUser(username);
        switch (a) {