public async Task CreateAsync(string userId, string refreshToken, string remoteIpAddress, string userAgent, TimeSpan refreshTokenLifetime)
 {
     var id     = GenerateId(refreshToken);
     var entity = new RefreshTokenDetails
     {
         Id           = id,
         UserId       = userId,
         RefreshToken = refreshToken,
         DateCreated  = DateTime.UtcNow,
         IpAddress    = remoteIpAddress,
         UserAgent    = userAgent,
         DateExpires  = DateTime.UtcNow + refreshTokenLifetime
     };
     await RavenDatabaseProvider.CreateEntity(entity);
 }
Пример #2
0
        public RefreshTokenDetails Upsert(RefreshTokenDetails domain)
        {
            var items = (from i in Context.Tokens
                         where i.ClientId == domain.ClientId
                         select i).LastOrDefault();

            if (items != null)
            {
                items.AccessToken            = domain.AccessToken;
                items.AccessTokenExpiresUtc  = domain.AccessTokenExpiresUtc;
                items.RefreshToken           = domain.RefreshToken;
                items.RefreshTokenExpiresUtc = domain.RefreshTokenExpiresUtc;
                items.IssuedUtc = domain.IssuedUtc;
            }
            else
            {
                Context.Tokens.Add(Mapper.Map <RefreshTokenDetails, Token>(domain));
            }
            Context.SaveChanges();
            return(null);
        }
Пример #3
0
 public RefreshTokenDetails Upsert(RefreshTokenDetails token)
 {
     return(AuthRepository.Upsert(token));
 }