コード例 #1
0
        public async Task StoreAsync(string key, Token value)
        {
            var result = await Collection.ReplaceOneAsync(
                Filter.ById(key),
                _serializer.Serialize(key, value),
                PerformUpsert).ConfigureAwait(false);

            Log.Debug(result.ToString);
        }
コード例 #2
0
        public BsonDocument Serialize(string key, RefreshToken value)
        {
            var doc = new BsonDocument();

            doc["_id"]        = key;
            doc["_version"]   = 1;
            doc["_expires"]   = value.CreationTime.AddSeconds(value.LifeTime).ToBsonDateTime();
            doc["_clientId"]  = value.ClientId;
            doc["_subjectId"] = value.SubjectId;
            var accessToken = new BsonDocument();

            _tokenSerializer.Serialize(accessToken, value.AccessToken);
            doc["accessToken"]  = accessToken;
            doc["creationTime"] = value.CreationTime.ToBsonDateTime();
            doc["lifetime"]     = value.LifeTime;
            doc["version"]      = value.Version;
            return(doc);
        }