Comments (4)
Hello, Is there any way you can have two suppliers for the same user?
from eloquent-oauth.
Hey, unfortunately this isn't supported automatically yet. It's also not a good idea to rely on the email address provided by Facebook/GitHub to determine if two users are the same.
More details on that here: #19
It sounds like you are saving the email like this, yeah?
OAuth::login('github', function ($user, $details) {
$user->email = $details->email;
$user->save();
});
Since you can't guarantee uniqueness of emails from third-parties and you can't guarantee two third party users are really the same user based on email, you either need to remove the unique constraint (guessing this is not an option and you are providing email/password login as well) or save the email to a different column or table. Maybe a contact_email
column that has no unique constraint.
Then implement a mutator on your User
class that looks something like:
public function getEmailAttribute()
{
return $this->attributes['email'] ?: $this->attributes['contact_email'];
}
...or check the oauth_identities
table explicitly if you'd like to confirm the user definitely came from a third party source and their email is stored somewhere else.
I'm considering adding the ability to link an existing third party account with a new third party account, so if you login with GitHub, you could click a link that says "link with Facebook" so you could then login with either option. Trying to support connecting two existing accounts however is beyond the scope of this project, because it involves combining all sorts of existing data that will be specific to your app. Like if you are building a Reddit type of app, I can't possibly know how to assign all of one user's comments to another user, because this package knows nothing about comments. Maybe I can come up with a decent API for getting that process started and leave the data merging to the implementer but I'll have to think about it.
from eloquent-oauth.
A simple solution might help others.....
In core package root directory Authenticator.php return the user in callback like bellow
if ($callback) {
$user = $callback($user, $userDetails);
}
and in your application
OAuth::login($provider, function ($user, $details) {
$exist = User::where('email', $details->email)->first();
if($exist){
$user = $exist;
}
$user->email = $details->email;
return $user;
});
You got the idea It works for me .... Thank you
pn: $provider (facebook, google, or github)
from eloquent-oauth.
@dhruba-sarma Yeah I was thinking that as well, great idea. Going to get that in the next release.
from eloquent-oauth.
Related Issues (20)
- Not catching ApplicationRejectedException when user reject facebook login HOT 3
- Add provider - Stripe [Request]
- Seems to be incompatible with Laravel 5.1 HOT 1
- Support passing custom data into the `state` param
- Provider Request: Reddit (code provided) HOT 7
- Class 'OAuth' not found HOT 2
- Add documentation for "Designing your users table"
- Rename OAuth facade HOT 2
- Support for twitter? HOT 3
- Request FACEBOOK basic data (gender, user_friends) HOT 1
- Office365 HOT 1
- Adding a 'remember' parameter to login() method HOT 1
- Retrieving The Authenticated User HOT 2
- Merging Accounts HOT 2
- Log in by access token HOT 2
- Using Google Oauth behind proxy
- Authorize more than one provider for one user HOT 1
- Running something on register HOT 1
- ΒΏIs There a way to auth sending email and password to Facebook or google?
- 'No query results for model [App\User].' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eloquent-oauth.