コード例 #1
0
ファイル: AccountController.cs プロジェクト: adgryz/FoodNet
        public async Task <IActionResult> RegisterUsr([FromBody] SignUpModel model)
        {
            var  id   = Guid.NewGuid();
            User user = new User
            {
                Id       = id,
                Email    = model.Email,
                Name     = model.Name,
                UserName = model.Name
            };
            var result = await _userManager.CreateAsync(user, model.Password);

            await _userManager.AddClaimAsync(user, new Claim(JwtClaimTypes.Email, model.Email));

            await _userManager.AddClaimAsync(user, new Claim(JwtClaimTypes.Role, "user"));

            _fridgeRepository.CreateFridgeForUser(id);
            return(Json(true));
        }