Results 1 to 8 of 8
  1. #1
    Constant Pligger voxxxlll's Avatar
    Joined
    Jun 2010
    Posts
    156

    Post Help user authentication

    Hi guys! Im trying to build a facebook login button.So far i built the script to get permission and all details about a user.In the file register.php i put an if statement like this:
    Code:
    if ($fblogin = true ) {
    
    run the script
    
    }
    Now if i have all details(name, password, email, avatar) how can i create a new user and authenticate him when $fblogin = true?

    In the file register.php i found this function but i dont know how to change it so i can use it for this.

    Code:
    function register_add_user($username, $email, $password, $password2){
    
    	global $current_user;
    
    	$user = new User();
    	$user->username = $username;
    	$user->pass = $password;
    	$user->email = $email;
    	if($user->Create()){
    
    		$user->read('short');
    		
    		$registration_details = array(
    			'username' => $username,
    			'password' => $password,
    			'email' => $email,
    			'id' => $user->id
    		);
    	
    		check_actions('register_success_pre_redirect', $registration_details);
    
    		$current_user->Authenticate($username, $password, false);
    		if ($registration_details['redirect'])
    		    header('Location: '.$registration_details['redirect']);
    		elseif(pligg_validate()){
    		    header('Location: '.my_base_url.my_pligg_base.'/register_complete.php?user='.$username);
    		} else {
    		    header('Location: ' . getmyurl('user', $username));
    		}
    		die();
    	}
    
    }
    Thank you!

  2. #2
    Pligg Founder Yankidank's Avatar
    Joined
    Dec 2005
    Location
    San Francisco, CA
    Posts
    5,063
    Site
    http://pligg.com/demo/
    Why don't you use the already-built Facebook Module?
    Facebook Connect Module for Pligg CMS | Pligg CMS Templates and Modules
    The Facebook Module for Pligg CMS!
    Register, Login, and Submit Stories with Facebook. An absolute MUST HAVE for all Pligg sites!

  3. #3
    Constant Pligger voxxxlll's Avatar
    Joined
    Jun 2010
    Posts
    156
    I would like to learn myself how to use facebook API and php.Could you please help me?Thank you!

  4. #4
    Pligg Developer chuckroast's Avatar
    Joined
    Jun 2006
    Posts
    5,478
    Honestly the facebook API changes so much. The best bet is to go with a provided solution. However there is nothing wrong with learning. If you want to re-learn their new api every week.

  5. #5
    Pligg Founder Yankidank's Avatar
    Joined
    Dec 2005
    Location
    San Francisco, CA
    Posts
    5,063
    Site
    http://pligg.com/demo/
    Quote Originally Posted by chuckroast View Post
    Honestly the facebook API changes so much. The best bet is to go with a provided solution. However there is nothing wrong with learning. If you want to re-learn their new api every week.
    So true. We've had to redo the official Facebook Connect Module 3 times so far, and we are about to do it a fourth time this week. It's really a pain.
    The Facebook Module for Pligg CMS!
    Register, Login, and Submit Stories with Facebook. An absolute MUST HAVE for all Pligg sites!

  6. #6
    Constant Pligger voxxxlll's Avatar
    Joined
    Jun 2010
    Posts
    156
    the problem is not facebook for me, the problem is that I don't know how to add a new user to pligg database and authenticate him, this was the question.

  7. #7
    Constant Pligger voxxxlll's Avatar
    Joined
    Jun 2010
    Posts
    156
    I found this function which encrypts the password

    function generateHash($plainText, $salt = null){

    if ($salt === null) {

    $salt = substr(md5(uniqid(rand(), true)), 0, SALT_LENGTH); }

    else {

    $salt = substr($salt, 0, SALT_LENGTH);

    }

    return $salt . sha1($salt . $plainText);

    }

    The password is saved in the database alright, but when i try to login says the pass is not correct.

  8. #8
    Constant Pligger voxxxlll's Avatar
    Joined
    Jun 2010
    Posts
    156
    This can be closed!Finally i added facebook login, twitter login and OpenID login without registration.

Similar Threads

  1. Google Authentication
    By aroopsharma in forum Questions & Comments
    Replies: 0
    Last Post: 01-23-2012, 01:26 PM
  2. Requiring authentication
    By verbalicious in forum Questions & Comments
    Replies: 9
    Last Post: 09-01-2010, 06:21 AM
  3. email id authentication
    By deepika in forum Questions & Comments
    Replies: 4
    Last Post: 03-06-2009, 05:09 AM
  4. User Authentication error in usre.php
    By kianu_riuz in forum Questions & Comments
    Replies: 2
    Last Post: 05-13-2008, 06:57 AM
  5. Authentication recognize www or not
    By aixelsyd in forum Questions & Comments
    Replies: 4
    Last Post: 12-03-2006, 01:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Pligg Modules and Pligg Templates from Pligg Pro Donate to Pligg CMS Dreamhost Web Hosting Host Gator Web Hosting