public IAuthentication Authenticate(AuthenticationRequest request) { _log.DebugFormat("Authenticate called with: {0}", request.ToString()); var token = SessionIdProvider.GetSessionId(); //login here... //_accounts. //var authentication = new Authentication(0,converter.Convert<IAuthentication>(request, resultDto, token, lightstreamerConfiguration)); //_log.DebugFormat("Login successful. Returning Authentication: {0}", authentication.ToDebugString()); //lock (_instanceLocker) //{ // var authenticationSession = new AuthenticationSession(authentication, TimeOutProvider.Now); // if (_authenticationSessionCache.ContainsKey(token)) // { // _authenticationSessionCache[token] = authenticationSession; // } // else // { // _authenticationSessionCache.Add(token, authenticationSession); // } //} //return authentication; return(null); }
public void SetGetSessionId() { // Arrange var sut = new SessionIdProvider(); var sessionId = Guid.NewGuid(); // Act sut.SetSessionId(sessionId); var actual = sut.GetSessionId(); // Assert Assert.Equal(sessionId, actual); }
public bool TryAuthenticate(string emailAddress, string password, out ServiceLoginToken token) { AccountPassword accountPassword = _accountPasswords.GetByEmail(emailAddress); if (accountPassword == null) { token = null; return(false); } if (accountPassword.Password != password) { token = null; return(false); } var tokenStr = _sessionIdProvider.GetSessionId(); var authenticationSession = new AuthenticationSession(accountPassword.Account, tokenStr, _nowProvider.Now); _authenticationSessionRepository.Add(authenticationSession); token = new ServiceLoginToken(tokenStr, accountPassword.Account.Id); return(true); }