senecajs / seneca-auth

A Seneca user authentication plugin for Hapi and Express
http://senecajs.org
MIT License
33 stars 29 forks source link

Implement support for authenticating using multiple strategies if use has same email on these accounts #72

Open mirceaalexandru opened 8 years ago

mirceaalexandru commented 8 years ago

If try to authenticate with Google/Github and user has same email on both accounts, second attempt will fail with nick-already-exists error.

girishla commented 8 years ago

+1

While we are doing this, it would be fantastic if we introduce the concept of a one to many association between user profile -> identities. Sort of like linked identities with one primary.

Like so

 "user": {
        "nick": "admin@concorda.com",
        "email": "admin@concorda.com",
        "name": "John Davids",
        "when": "2016-02-26T11:56:10.722Z",
        "primaryIdentity": "353333",
        "id": "37yglp",
        "identities": [
            {
                "identityId": "353333",                
                "type": "social",
                "token": "87hkkdww-jqwdkqu73647",
                "expires_at": "2016-06-26T11:56:10.722Z",
                "connection": "google-oauth2",
                "userId": "userid_12345"
            },
            {
                "identityId": "978686",        
                "type": "ldap",
                "token": "9b9ba9ca-770b-35335353534",
                "expires_at": "2017-02-01T00:00:00.722Z",
                "connection": "azure-ldap",
                "userId": "ldapaccount_349759437"
            }
        ]
    }

So for instance the user can use the same concorda user profile with multiple identity providers. If a new id provider is used to authenticate and a match is found based on email Ids, we can use the new provider to enrich the existing profile.

This would obviously need changes to seneca-user too. Although not a trivial addition, it would open up a world of possibilities for users of seneca-auth.

mirceaalexandru commented 8 years ago

@girishla I agree, we already discussed about such scenario in Concorda.

girishla commented 8 years ago

@mirceaalexandru great then I'll keep an eye out for it. Let me know if I can help in any way.

mirceaalexandru commented 8 years ago

@girishla Don't know exactly when this will be done as there are some other things in the queue :(

girishla commented 8 years ago

@mirceaalexandru Understood. Keep up the good work :thumbsup: