Exemple #1
0
        public void ApiAuthValidate_Test()
        {
            var client = new DiscuzApiClient();

            var uid = client.AuthValidate("cyrano", Encrypt.GetMd5Hash("linfeng"));

            Assert.AreEqual(443, Convert.ToInt32(uid.Replace("\"", "")));
        }
Exemple #2
0
        //
        // Summary:
        //     Verifies that the supplied user name and password are valid.
        //
        // Parameters:
        //   username:
        //     The name of the user to be validated.
        //
        //   password:
        //     The password for the specified user.
        //
        // Returns:
        //     true if the supplied user name and password are valid; otherwise, false.
        //public static bool ValidateUser(string username, string password, out object providerUserKey)
        //{
        //    Contract.Requires(!string.IsNullOrEmpty(username));
        //    Contract.Requires(!string.IsNullOrEmpty(password));

        //    IRepository repo = new Repository();

        //    var query = repo.Query<Membership>(x =>
        //        x.UserName == username && x.Password == Encrypt.GetMd5Hash(password));

        //    if (query.Count > 0)
        //    {
        //        var membership = query[0];

        //        providerUserKey = membership.ID;

        //        membership.LastLoginDate = DateTime.Now;
        //        repo.Update(membership);
        //    }
        //    else
        //    {
        //        providerUserKey = null;
        //    }

        //    return query.Count > 0;
        //}

        public static bool ValidateAcnUser(string username, string password, out int acnUid)
        {
            acnUid = -1;

            if (!ConfigGlobal_Arsenal.AcnSync)
            {
                return(false);
            }

            var client = new DiscuzApiClient();

            var uid = client.AuthValidate(username, Encrypt.GetMd5Hash(password));

            return(int.TryParse(uid.Replace("\"", ""), out acnUid));
        }