Esempio n. 1
0
        public async ValueTask LogAsync(Auditlog <TUserBrief> auditlog)
        {
            auditlog.Operator = await userServices.FindFirstAsync(
                u => u.Id == auditlog.Operator.Id, u => mapper.Map <TUserBrief>(u));

            await collection.InsertOneAsync(auditlog);
        }
        public override async Task ValidatePrincipal(CookieValidatePrincipalContext context)
        {
            var userPrincipal = context.Principal;
            var userId        = Guid.Parse(userPrincipal.Identity.Name);
            var StampInDb     = await userService.FindFirstAsync(t => t.Id == userId, t => t.SecurityStamp);

            var StampInCookie = (from item in userPrincipal.Claims
                                 where item.Type == "SecurityStamp"
                                 select item.Value).FirstOrDefault();

            if (StampInCookie != StampInDb)
            {
                context.RejectPrincipal();

                await context.HttpContext.SignOutAsync(
                    CookieAuthenticationDefaults.AuthenticationScheme);
            }
        }