public async Task <IActionResult> SetIamPolicy([FromBody] UserPolicyDto model)
        {
            //var _userId = this.HttpContext.User.Claims.First(c => c.Type == "sub").Value;
            await _appUserService.SetPolicy(model);

            return(Ok());
        }
Ejemplo n.º 2
0
        public async Task SetPolicy(UserPolicyDto userPolicy)
        {
            foreach (var email in userPolicy.Emails)
            {
                // get user data
                var user = await _userManager.FindByEmailAsync(email);

                if (user == null)
                {
                    user = await AddUserByEmailWithoutPassword(email);
                }

                await _userManager.AddToRolesAsync(user, userPolicy.Roles);
            }
        }