How to restrict posts only from a certain category

try this:

<?php 
    //first check if its the category in question
    if ($cat == '1') { 
        //then if the user is logged in show the content
        if (is_user_logged_in()){
            the_content();
        }else{ //if not show the excerpt
            the_excerpt();
        }
    }else{ // and if its not the category show the content
        the_content();
    }
?> 

Update

Judging by your comments you are some defining $cat before the check so add:

$cat = get_query_var('cat');

before the conditional code.