Example #1
0
        public async Task <RefreshToken> SendAuthCookies(AppUser user)
        {
            var(aid, rid, sid) = await tokenGenerator.GenerateRequired(user);

            contextAccessor.HttpContext.Response.Cookies.Append("_aid", aid, new CookieOptions {
                Expires = DateTime.UtcNow.AddMinutes(30), HttpOnly = true, Secure = false, SameSite = SameSiteMode.Unspecified, Domain = "localhost"
            });
            contextAccessor.HttpContext.Response.Cookies.Append("_rid", rid, new CookieOptions {
                Expires = DateTime.UtcNow.AddDays(2), HttpOnly = true, Secure = false, SameSite = SameSiteMode.Unspecified, Domain = "localhost"
            });
            contextAccessor.HttpContext.Response.Cookies.Append("_sid", sid, new CookieOptions {
                Expires = DateTime.UtcNow.AddDays(2), HttpOnly = false, Secure = false, SameSite = SameSiteMode.Unspecified, Domain = "localhost"
            });
            return(new RefreshToken
            {
                Token = rid,
                CreatedAt = DateTime.UtcNow,
                ExpireAt = DateTime.UtcNow.AddDays(2),
                AppUser = user
            });
        }