public async Task RefreshSessionAsync(Guid sessionId, Guid newSessionId, string sessionKey, string ipAddress = null, string userAgent = null) { var parentSession = await _userSessionRepository.GetByIdAsync(sessionId); if (parentSession.HasNoValue) { throw new ServiceException(OperationCodes.SessionNotFound, $"Session with id '{sessionId}' has not been found."); } if (parentSession.Value.Key != sessionKey) { throw new ServiceException(OperationCodes.InvalidSessionKey, $"Invalid session key: '{sessionKey}'"); } var newSession = parentSession.Value.Refresh(newSessionId, _encrypter.GetRandomSecureKey(), sessionId, ipAddress, userAgent); await _userSessionRepository.AddAsync(newSession); await _userSessionRepository.DeleteAsync(sessionId); }
public async Task LogoutAsync(string id) { await userSessionRepository.DeleteAsync(id); }