Exemple #1
0
        public static bool check(string user, string passwd)
        {
            user = user.ToLower();
            User user1 = UserDb.lookup(user);

            return(user1 != null && (user1.passwd == passwd || user == "anonymous" || (SimpleHash.test_hash(passwd, user1.passwd) || UserDb.digest_passwd(user, passwd) == user1.passwd) || UserDb.decode_passwd(user, user1.passwd) == passwd));
        }
Exemple #2
0
        public static bool add(
            string user,
            string passwd,
            NameValueCollection info,
            out string reason,
            string oldpass)
        {
            if (Vuser.total > 5 && Vuser.total > MyKey.ulimit_max())
            {
                reason = "Sorry license user limit reached";
                return(false);
            }
            if (!Vuser.valid_user(user, out reason))
            {
                return(false);
            }
            User user1 = UserDb.lookup(user);
            bool flag  = UserDb.add(user, passwd, info, user1 == null ? "" : user1.passwd, out reason);

            if (flag && user1 == null)
            {
                Vuser.total_add(1);
            }
            return(flag);
        }
Exemple #3
0
        public static bool unit_test()
        {
            NameValueCollection nameValueCollection = new NameValueCollection()
            {
                {
                    "Full Name",
                    "Bob Jones"
                },
                {
                    "Created",
                    "23 January 1966"
                }
            };
            User user = UserDb.lookup("*****@*****.**");

            if (user != null)
            {
                clib.imsg("lookup found user {0}", (object)user.ToString());
            }
            return(true);
        }
Exemple #4
0
 public static User lookup(string user)
 {
     return(UserDb.lookup(user));
 }
Exemple #5
0
        public static bool check(string user, string pass, out string reason)
        {
            bool flag1 = false;

            reason = "user doesn't exist or invalid password";
            bool flag2 = UserDb.check(user, pass);

            if (flag2)
            {
                User user1 = UserDb.lookup(user);
                flag1 = user1.isadmin();
                switch (user1.info["status"])
                {
                case "pending":
                    reason = "Sorry you must activate using the token from your email first";
                    return(false);

                default:
                    string stuff = user1.info["cached"];
                    if (stuff != null && stuff.Length > 0)
                    {
                        clib.imsg("found cached life of {0}", (object)stuff);
                        if (clib.time() > clib.atoi(stuff))
                        {
                            clib.imsg("EXPIRED, MAKE HIM CHECK AGAIN age {0} {1}", (object)(clib.time() - clib.atoi(stuff)), (object)stuff);
                            flag2 = false;
                        }
                    }
                    break;
                }
            }
            if (!flag1 && !Vuser.valid_user(user, out reason))
            {
                return(false);
            }
            if (!flag2)
            {
                string dest = Ini.getstring(En.auth_imap);
                if (dest.Length > 0)
                {
                    Imap imap = new Imap();
                    clib.imsg("auth_imap {0} {1}", (object)user, (object)dest);
                    string result;
                    if (imap.login(dest, 143, "nossl", user, pass, out result))
                    {
                        NameValueCollection info = new NameValueCollection();
                        User user1 = UserDb.lookup(user);
                        if (user1 != null && user1.info != null)
                        {
                            info = user1.info;
                        }
                        info.Set("cached", clib.int_to_string(clib.time() + 604800));
                        clib.imsg("Imap: login worked for that user/pass {0}", (object)user);
                        string reason1;
                        if (!UserDb.add(user, pass, info, "", out reason1))
                        {
                            clib.imsg("cacheadd: {0}", (object)reason1);
                        }
                        imap.netclose();
                        flag2 = true;
                    }
                    else
                    {
                        clib.imsg("imap: login failed on remost host {0}", (object)result);
                    }
                }
            }
            return(flag2);
        }
Exemple #6
0
        public static string get_pass(string user)
        {
            User user1 = UserDb.lookup(user);

            return(user1 == null ? "" : UserDb.decode_passwd(user, user1.passwd));
        }