コード例 #1
0
        public async void PasswordTesting()
        {
            NHibernateUserStore store = new NHibernateUserStore();
            var usr = await store.FindByIdAsync("ef9826e1-86b8-41c4-8716-a9e60123db20");

            await store.SetPasswordAsync(usr, "test2");
        }
コード例 #2
0
        // GET: Confirmation
        public async Task <ActionResult> DriverConfirmation()
        {
            string id = null;

            var       nhs = new NHibernateUserStore();
            UserModel usr = null;

            if (HttpContext.Session["UserId"] != null)
            {
                id = HttpContext.Session["UserId"].ToString();
            }
            if (id == null)
            {
                usr = await nhs.FindByStampAsync(CurrentUserSession.userSecurityStampCookie);
            }
            else
            {
                usr = await nhs.FindByIdAsync(id);
            }
            ViewData["ApiServer"] = Config.GetApiServerURL();


            if (usr == null || !usr.IsAdmin)
            {
                RedirectToAction("Login", "Logins");
            }
            var hds     = new NHibernateDriverStore();
            var drivers = await hds.GetAllForValidationAsync();

            return(View(drivers));
        }
コード例 #3
0
        // POST api/<controller>
        public async Task <string> Post(RegistrationSatusModel value)
        {
            string    id     = null;
            string    result = "Ok";
            var       nus    = new NHibernateUserStore();
            UserModel user   = null;

            if (HttpContext.Current.Session["UserId"] != null)
            {
                id = HttpContext.Current.Session["UserId"].ToString();
            }
            if (id == null)
            {
                user = await nus.FindByStampAsync(CurrentUserSession.userSecurityStampCookie);
            }
            else
            {
                user = await nus.FindByIdAsync(id);
            }

            var nds = new NHibernateDriverStore();

            var driver       = nds.FindByIdAsync(value.Id).Result;
            var existingUser = await nus.FindByNameAsync(driver.Email);

            driver.Status    = RegistrationStatus.Accepted;
            driver.UpdatedBy = user;
            if (existingUser != null)
            {
                existingUser.Driver = driver;
                await nus.UpdateAsync(existingUser);
            }
            else
            {
                var usr = new UserModel {
                    UserName      = driver.Email,
                    FirstName     = driver.FirstName,
                    LastName      = driver.LastName,
                    PasswordHash  = driver.Password,
                    SecurityStamp = Guid.NewGuid().ToString(),
                    Driver        = driver
                };
                await nus.CreateAsync(usr);
            }
            var emails = driver.Email;
            await Emailer.SendMessage(driver.Email + " Activated", emails, "Registration");

            return(result);
        }