Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Twitter login - Only if user have an account

Any ideas on how to only let user who already signed up to log in and the user who not signed up gets pushed to signup? I only want the user to be able to log in with twitter if the user already is signed up and is linked with a user.

This is my code now:

´´´

IBAction)twitterLogin:(id)sender { {

    {



        [PFTwitterUtils logInWithBlock:^(PFUser *user, NSError *error) {


         if (error) {


             [self dismissViewControllerAnimated:NO completion:nil];
             [self performSegueWithIdentifier:@"twitterSetup" sender:self];

             NSLog(@"Don't have an account.");
             return;
             UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@""
                                                                 message:@"In order to log in with Twitter you need to sign up a user first"
                                                                delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];


             [alertView show];
             [hud hide:YES];



            } else if (user){



                NSLog(@"User logged in with Twitter!");

                NSString *twitterScreenName = [PFTwitterUtils twitter].screenName;
                [[PFUser currentUser] setObject:twitterScreenName forKey:@"username"];
                [[PFUser currentUser] saveInBackground];

                [hud hide:YES];
                [self dismissViewControllerAnimated:YES completion:nil];
                [self.navigationController popToRootViewControllerAnimated:YES];



            }
        }];

    }
}

}

Thanks!

´´´