Пример #1
0
        /// <summary>
        /// Adds the refresh token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns></returns>
        public async Task<bool> AddRefreshToken(RefreshToken token)
        {

            var existingToken = _ctx.RefreshTokens.Where(r => r.Subject == token.Subject && r.ClientId == token.ClientId).SingleOrDefault();

            if (existingToken != null)
            {
                var result = await RemoveRefreshToken(existingToken);
            }

            _ctx.RefreshTokens.Add(token);

            return await _ctx.SaveChangesAsync() > 0;
        }
Пример #2
0
 /// <summary>
 /// Removes the refresh token.
 /// </summary>
 /// <param name="refreshToken">The refresh token.</param>
 /// <returns></returns>
 public async Task<bool> RemoveRefreshToken(RefreshToken refreshToken)
 {
     _ctx.RefreshTokens.Remove(refreshToken);
     return await _ctx.SaveChangesAsync() > 0;
 }