• 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multi login in codeignter

#1
Hello guys thanks for answering questions few days ago, i have system multi ( register, login and logout ) using facebook, twitter, (manual input type information users )

here is my table --> id_user, email, name, password  (only thi field is important)

i have success
  1. Create register, login and logout manual in codiegnter by input some field
  2. Create login facebook without insert data users to database


what i have not create
  1. Login Twitter 



My question
  1. how possible when users register by facebook then login in twitter or other
  2. am i wrong to said that to my boss when users register by facebook they only can login by facebook too, when they are trying another way to login it cannot
  3. when user register in facebook or twitter can i store their email and id_user (generate by auto increment)
  4. let say when user login by facebook or twitter when input master products can i get their id_users


this system need the id from users so it give me blank   Confused  idea firt time

IF you guys have experience about this please share something idea to me as new bie especially Codeignter 3
Reply

#2
Check out the A3M project. They do exactly that. There's a way to link your account to your facebook or twitter account so you can log with any method available.

https://github.com/donjakobo/A3M
Test your translation files with Translation Tester
Reply

#3
Essentially, you keep the data required to perform authentication separate from the user information and use a foreign key to link the user data to the authentication data. Then, once the user is logged in with one authentication method, you can allow them to associate other authentication methods with their account, so they can log in using whichever method they wish. For example, you might have a user table and your PHP authentication table look something like this:

Code:
user {
  id unsigned bigint(20) auto_increment not null,
  display_name varchar(255) not null,
  contact_email varchar(255) not null
}

php_auth {
  login_email varchar(255) not null,
  password varchar(255) not null,
  user_id unsigned bigint(20) not null
}

facebook_auth {
  facebook_id unsigned bigint(20) not null,
  // any other data needed for facebook
  user_id unsigned bigint(20) not null
}

So, when a user creates a new account, you would insert their user information in the user table, get the inserted ID, then create the entry in the appropriate *_auth table, using the inserted ID from the user table as the user_id in the *_auth table(s). If they want to add an additional authentication method to their existing account, you authenticate them and insert their user ID and other relevant information into the appropriate *_auth table.

When they log in, you look up their information in the *_auth table appropriate to the method they used to log in, then use the user_id to get their account info. If they log in with Facebook or Twitter and don't have an entry in the *_auth table, you can let them know that you've created a new account using the information you retrieved from Facebook/Twitter, and give them the opportunity to instead associate their Facebook/Twitter login with an existing account, if they can authenticate with whatever authentication method was previously used on that account.
Reply

#4
(09-12-2015, 12:26 PM)includebeer Wrote: Check out the A3M project. They do exactly that. There's a way to link your account to your facebook or twitter account so you can log with any method available.

https://github.com/donjakobo/A3M

Than for respon i just saw an dlearn it yesterday but hard to understand it, is there any tutorial you had about this issue login media social and get the id_user
Reply

#5
(09-14-2015, 08:18 AM)mwhitney Wrote: Essentially, you keep the data required to perform authentication separate from the user information and use a foreign key to link the user data to the authentication data. Then, once the user is logged in with one authentication method, you can allow them to associate other authentication methods with their account, so they can log in using whichever method they wish. For example, you might have a user table and your PHP authentication table look something like this:


Code:
user {
 id unsigned bigint(20) auto_increment not null,
 display_name varchar(255) not null,
 contact_email varchar(255) not null
}

php_auth {
 login_email varchar(255) not null,
 password varchar(255) not null,
 user_id unsigned bigint(20) not null
}

facebook_auth {
 facebook_id unsigned bigint(20) not null,
 // any other data needed for facebook
 user_id unsigned bigint(20) not null
}

So, when a user creates a new account, you would insert their user information in the user table, get the inserted ID, then create the entry in the appropriate *_auth table, using the inserted ID from the user table as the user_id in the *_auth table(s). If they want to add an additional authentication method to their existing account, you authenticate them and insert their user ID and other relevant information into the appropriate *_auth table.

When they log in, you look up their information in the *_auth table appropriate to the method they used to log in, then use the user_id to get their account info. If they log in with Facebook or Twitter and don't have an entry in the *_auth table, you can let them know that you've created a new account using the information you retrieved from Facebook/Twitter, and give them the opportunity to instead associate their Facebook/Twitter login with an existing account, if they can authenticate with whatever authentication method was previously used on that account.

thanks a lot mwhitney but it seems hard to applicated it, do you have simple tutorial or demo about it, need one day to get know login using facebook without insert data users to databse, it will spend more time for me. if is there any tutorial please drop here uncle need some help and advice, thanks for you advice will try it after know how to get data users from twitter also facebook, 
Reply

#6
(09-14-2015, 07:29 PM)freddy Wrote:
(09-12-2015, 12:26 PM)includebeer Wrote: Check out the A3M project. They do exactly that. There's a way to link your account to your facebook or twitter account so you can log with any method available.

https://github.com/donjakobo/A3M

Than for respon i just saw an dlearn it yesterday but hard to understand it, is there any tutorial you had about this issue login media social and get the id_user

I don't have any tutorial but you can study the code. You have a working example, that's the best tutorial you can get!
Test your translation files with Translation Tester
Reply

#7
(09-15-2015, 04:24 PM)includebeer Wrote:
(09-14-2015, 07:29 PM)freddy Wrote:
(09-12-2015, 12:26 PM)includebeer Wrote: Check out the A3M project. They do exactly that. There's a way to link your account to your facebook or twitter account so you can log with any method available.

https://github.com/donjakobo/A3M

Than for respon i just saw an dlearn it yesterday but hard to understand it, is there any tutorial you had about this issue login media social and get the id_user

I don't have any tutorial but you can study the code. You have a working example, that's the best tutorial you can get!
do you have any experience about this issue includebeer ? the link you have given to me is it avaiable for codeignter 3 ?

i have been testing your link above but i don't ghet the point how to register users and get in the login  Undecided 
Reply

#8
(09-15-2015, 07:35 PM)freddy Wrote: do you have any experience about this issue includebeer ? the link you have given to me is it avaiable for codeignter 3 ?

i have been testing your link above but i don't ghet the point how to register users and get in the login  Undecided 

Like mwhitney explained, you have to link all the login method to one user database. That way, the users can use any method available to log in. Install A3M on a test site, you will see in your profile page a way to link your facebook or twitter account to the same user. Then you can use one way or the other to login and you won't have duplicate user.

And yes it's available for CI3, just change the  branch for ci3-beta : https://github.com/donjakobo/A3M/tree/ci3-beta
Test your translation files with Translation Tester
Reply

#9
As includebeer pointed out, the A3M code is probably the best we can do for you. In most cases the biggest step in going from a single authentication method to multiple methods is to move the fields currently required for authentication out of your users table. Once you've put them in a separate table with a user_id foreign key to look up the user information, it's relatively simple to add additional methods of authentication. The hardest part at that point is figuring out how to do something specific like Facebook authentication, and you can probably find tutorials for each form of authentication you need to support, you'll just have to rework them for your specific needs.
Reply

#10
(09-16-2015, 04:53 AM)includebeer Wrote:
(09-15-2015, 07:35 PM)freddy Wrote: do you have any experience about this issue includebeer ? the link you have given to me is it avaiable for codeignter 3 ?

i have been testing your link above but i don't ghet the point how to register users and get in the login  Undecided 

Like mwhitney explained, you have to link all the login method to one user database. That way, the users can use any method available to log in. Install A3M on a test site, you will see in your profile page a way to link your facebook or twitter account to the same user. Then you can use one way or the other to login and you won't have duplicate user.

And yes it's available for CI3, just change the  branch for ci3-beta : https://github.com/donjakobo/A3M/tree/ci3-beta


yes i do design my database like mwhtiney said above then i have download and test it in my localhost but the first time i register my self then change the status from database and log in to system but there is no menu to make my account register to facebook or twitter, only has menu for profile, change the password and connect link to the account (not found i don't know why because i just fixed my htacsess to make it running). Connect link to the account is it for connect my account to media social ?

all i do in my htacsess from the oribinal file just remove this line RewriteBase / if not remove it it give me redirect to http://localhost/xampp/splash.php i use windows
Code:
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^$ /index.php [L]
RewriteCond $1 !^(index\.php|resource|system|user_guide_src|bootstrap|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

my question 
  1. what should i change in htacsess to make my projects become running well
  2. after running well is it need to hosting to testing ?
sorry to much asking here but it give me errors, thanks for your comment includebeer
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.