Пример #1
0
        private AppUser CheckUser(string username, string password)
        {
            List<AppUser> Users = new List<AppUser>()
            {
                new AppUser()
                {
                    UserName= "******",
                    PasswordHash = "123456"
                },
                new AppUser() {
                    UserName= "******",
                    PasswordHash = "12345678"
                }
            };

            var user = new AppUser
            {
                UserName = username,
                PasswordHash = password
            };
            bool bl = false;
            Users.ForEach(x =>
            {
                if (x.UserName.Equals(user.UserName) && x.PasswordHash.Equals(x.PasswordHash))
                    bl = true;
            });
            if (bl)
                return user;
            else
                return null;
        }
Пример #2
0
 public async Task<ActionResult> Create(string username, string password, string email, string cfield)
 {
     if (ModelState.IsValid)
     {
         var user = new AppUser { UserName = username, Email = email, CusField = cfield };
         //传入Password并转换成PasswordHash
         IdentityResult result = await UserManager.CreateAsync(user,
             password);
         if (result.Succeeded)
         {
             return RedirectToAction("Index");
         }
         //AddErrorsFromResult(result);
     }
     return View();
 }