public async Task <AuthResponse> LoginTicketAuth([FromBody] AuthRequest authRequest) { var sessionLookup = new SessionLookup(); sessionLookup.sessionKey = authRequest.login_ticket; var session = (await sessionRepository.Lookup(sessionLookup)).FirstOrDefault(); if (session == null) { throw new AuthInvalidCredentialsException(); } var response = new AuthResponse(); var proof = GetPasswordProof(session.profile, authRequest, ProofType.ProofType_LoginTicket, true); if (proof.CompareTo(authRequest.client_response) != 0) { throw new AuthInvalidCredentialsException(); } response.server_response = GetPasswordProof(session.profile, authRequest, ProofType.ProofType_LoginTicket, false); response.profile = session.profile; response.user = session.user; response.session = await generateSessionKey(response.profile); response.success = true; return(response); }
public async Task <SessionDeleteResponse> DeleteSession([FromBody] SessionLookup request) { var resp = new SessionDeleteResponse(); resp.success = await this.sessionRepository.Delete(request); return(resp); }
public async Task <Session> GetSession([FromBody] AuthRequest request) { var lookup = new SessionLookup(); lookup.sessionKey = request.password; var session = (await sessionRepository.Lookup(lookup)).FirstOrDefault(); return(session); }
public void SessionDisconnected(ToffeeSession session) { if (session.SessionId >= UniqueIdentifiers.Count) { return; } UniqueIdentifiers[session.SessionId] = false; _Sessions.Remove(session); SessionLookup.Remove(session.SessionId); if (Server.Log != null) { Server.Log.Info("Session {0} disconnected.", session.SessionId); } Server.SessionDisconnected(); }
public void NewSession(ToffeeSession session) { session.SessionId = GetUniqueIdentifier(); _Sessions.Add(session); SessionLookup.Add(session.SessionId, session); }