private AuthResponse <T> Authenticate <T>(string token, Func <T> callback) { AuthState authState = _WebServer.CheckAuth(Context.ConnectionId, token); if (authState == AuthState.Authenticated) { Groups.Add(Context.ConnectionId, GROUP_AUTHED); return(AuthResponse <T> .Authenticated(callback.Invoke())); } Groups.Remove(Context.ConnectionId, GROUP_AUTHED); return(AuthResponse <T> .NotAuthenticated(authState)); }
public AuthResponse <string> Login(string password) { string token = _WebServer.CreateToken(password); AuthState authState = _WebServer.Login(Context.ConnectionId, token); if (authState == AuthState.Authenticated) { Groups.Add(Context.ConnectionId, GROUP_AUTHED); return(AuthResponse <string> .Authenticated(token)); } Groups.Remove(Context.ConnectionId, GROUP_AUTHED); return(AuthResponse <string> .NotAuthenticated(authState)); }