Пример #1
0
        public IOAuthAccessToken GetUserOAuthToken(IEntitySession session, Guid userId, string serverName, string accountName = null)
        {
            accountName = accountName ?? Settings.DefaultAccountName;
            var context     = session.Context;
            var utcNow      = context.App.TimeService.UtcNow;
            var accessToken = session.EntitySet <IOAuthAccessToken>()
                              .Where(t => t.Account.Server.Name == serverName && t.UserId == userId && t.Status == OAuthTokenStatus.Active)
                              .OrderByDescending(t => t.RetrievedOn).FirstOrDefault();

            if (accessToken != null && accessToken.ExpiresOn < utcNow)
            {
                session.UpdateStatus(accessToken.Id, OAuthTokenStatus.Expired); //update directly in db
                return(null);
            }
            return(accessToken);
        }
Пример #2
0
 public void UpdateTokenStatus(IEntitySession session, Guid tokenId, OAuthTokenStatus status)
 {
     session.UpdateStatus(tokenId, status);
 }