Ejemplo n.º 1
0
        public async Task<IHttpActionResult> Register(RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var user = new ApplicationUser() { UserName = model.Email, Email = model.Email };

            IdentityResult result = await UserManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                return GetErrorResult(result);
            }

            return Ok();
        }
Ejemplo n.º 2
0
        public async Task<IHttpActionResult> Register(RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            // using simple membership authentication
            var user = new ApplicationUser() { UserName = model.Email, Email = model.Email };
            IdentityResult result = await UserManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                return GetErrorResult(result);
            }

            //create the standard free system account
            var accountCreated = CreateOrUpdateFreeStandardAccount(user.UserName);
            if (null == accountCreated)
            {
                ModelState.AddModelError("SocialSytemError", "System account could not be created");
                return BadRequest(ModelState);
            }
            
            return Json(accountCreated.Email);
        }