Пример #1
0
        public async Task <object> Update([FromBody] UserRegister model)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            user.FirstName = model.FirstName;
            user.LastName  = model.LastName;

            await _userManager.UpdateAsync(user);

            return(new ObjectResult(user));
        }
Пример #2
0
        public async Task <object> Register([FromBody] UserRegister model)
        {
            var user = new ApplicationUser
            {
                FirstName = model.FirstName,
                LastName  = model.LastName,
                UserName  = model.Email,
                Email     = model.Email
            };
            var result = await _userManager.CreateAsync(user, model.Password);

            if (result.Succeeded)
            {
                await _signInManager.SignInAsync(user, false);

                return(GenerateJwtToken(model.Email, user));
            }

            return(null);
        }