Esempio n. 1
0
        private async Task AddExtraInfo(ApplicationUser user, RegisterBindingModel model)
        {
            throw new NotImplementedException();
            ////TODO: Get from settings in db;
            ////var defaultAvatarUrl = "http://ci.quilt4.com/master/web/images/avatar5.png";
            //var defaultAvatarUrl = (string)null;

            //try
            //{
            //    //TODO: Access through business layer
            //    _repository.AddUserExtraInfo(user.UserName, model.FirstName, model.LastName, defaultAvatarUrl);
            //}
            //catch (Exception)
            //{
            //    throw;
            //}
        }
Esempio n. 2
0
        private async Task<IdentityResult> AutoAdminAssignment(ApplicationUser user)
        {
            throw new NotImplementedException();
            //var autoAdminCountString = System.Configuration.ConfigurationManager.AppSettings["AutoAdminCount"];
            //int autoAdminCount;
            //if (!int.TryParse(autoAdminCountString, out autoAdminCount))
            //{
            //    autoAdminCount = 2;
            //}

            //IdentityResult result = null;
            //if (UserManager.Users.Count() <= autoAdminCount)
            //{
            //    var role = await RoleManager.FindByNameAsync(Constants.Administrators);
            //    if (role == null)
            //    {
            //        result = await RoleManager.CreateAsync(new ApplicationRole { Name = Constants.Administrators });
            //    }

            //    if (result == null || result.Succeeded)
            //    {
            //        var userId = UserManager.FindByName(user.UserName).Id;
            //        result = await UserManager.AddToRoleAsync(userId, Constants.Administrators);
            //    }
            //}

            //return result;
        }
Esempio n. 3
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Username };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                    await SignInManager.PasswordSignInAsync(model.Username, model.Password, false, false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return RedirectToAction("Index", "Home");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }