コード例 #1
0
        public async Task SetClaimsAsync(OdissUser user, IList <Claim> claims)
        {
            var session = await sessionStore.GetByUserIdAsync(user.Id);

            if (session == null)
            {
                throw new NullReferenceException("No session for user found");
            }

            session.Data = serialization.Serialize(claims);

            await sessionStore.UpdateAsync(session);
        }
コード例 #2
0
        /// <summary>
        /// Extends the session by the configured maximum session timeout
        /// </summary>
        public async Task ExtendAsync(TSessionKey sessionId)
        {
            var session = await store.GetAsync(sessionId);

            session.ExpiryDate   = DateTime.Now.Add(MaximumSessionTimeout);
            session.LastActionAt = DateTime.Now;

            await store.UpdateAsync(session);

            logger.LogSystemActivity("User Session Extended", session.ToLogMessage());

            var deletedSessions = await store.ClearSessionsAsync();

            if (deletedSessions.Any())
            {
                logger.LogSystemActivity("Expired User Sessions Deleted", deletedSessions.Select(x => x.ToLogMessage()));
            }
        }