Ejemplo n.º 1
0
        public async Task <Account> Resolve(DocumentIOResolveFieldContext <object> context)
        {
            var accountId   = context.GetAccountId();
            var httpContext = context.GetHttpContext();

            var account = await databaseContext.Accounts
                          .SingleAsync(x => x.Id == accountId);

            await httpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);

            return(account);
        }
Ejemplo n.º 2
0
        public async Task <Account> Resolve(DocumentIOResolveFieldContext <object> context)
        {
            var httpContext = context.GetHttpContext();
            var input       = context.GetArgument <Account>();

            var account = await databaseContext
                          .Accounts
                          .SingleAsync(x => x.Email == input.Email);

            await httpContext.SignInAsync(
                CookieAuthenticationDefaults.AuthenticationScheme,
                new ClaimsPrincipal(new ClaimsIdentity(new[]
            {
                new Claim(ClaimTypes.Name, account.Id.ToString()),
                new Claim(ClaimTypes.Role, account.Role)
            })));

            return(account);
        }