Utopian Registration: Backend - Social Login with Github, Facebook & LinkedIn

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@therealwolf·
0.000 HBD
Utopian Registration: Backend - Social Login with Github, Facebook & LinkedIn
![Utopian_wolf.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515786866/r8mdgrgtgk4gtzca511u.png)

Hello everybody,

this Contribution Post is part of the Utopian Registration-Project.

The goal for the Utopian Registration is, to allow People who are new to STEEM to create an Utopian ( STEEM ) - Account through Utopian itself (and not how it is currently handled, through STEEMIT).

And one of the most important groundworks for this, is the actual login with a Github, Facebook or LinkedIn account.

In this Contribution-Post I'll take you through the changes I've made to the *utopian-api-backend* and what is working right now.

You can check out the changes I made to the frontend in <a href="https://utopian.io/utopian-io/@therealwolf/utopian-registration-frontend-social-login-with-github-facebook-and-linkedin">this post.</a>

<h1>The Pull-Request</h1>

![image.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515542045/kzsaqxkk8sxisquhtgtr.png)

You can find the pull-request here: <a href="https://github.com/utopian-io/api.utopian.io/commit/ef5864af7ce9aec2829db15d03ebeb3aaa7c8cad">Pull Request</a>

<h1>The Logic</h1>

While the frontend was pretty much straight forward - the backend needed a bit of creativity.

The reason for this is, because there are happening several things when a user logs in via social login.

<h2>1.) Get User</h2>

After some internal logic with access_tokens and oAuth2 where the user is getting logged in - we receive a code which can be used to retrive the data from the social provider - Github, Facebook and linkedin. (However, LinkedIn  gave some problems so it isn't used right now).

<h2>2.) Analyse and create User in DB</h2>

This data was then used to rate the user and to see if he was already verified by the social provider - for example through 2FA or something similar and then a temporary user is created - which is for keeping track of the current status of the user.

For example: if the user has already created a STEEM account or if he still needs to verify SMS / Email. And some data about the user.

<h2>3.) Redirect User</h2>

After this, the user will be redirected on the frontend to the right site. 

Which means - if he has verified Email & SMS OR Email & Social-Account (2FA in Github e.g.) then he gets redirected to the Steem-Account Name-Selection.

If he hasn't verified anything - then he gets redirected to email verification.

<h1>What's next?</h1>

Next up for me is the email verification and SMS verification. While those are both things that I also haven't done before - I'm happy for the challenge.

So - until then,

-Wolf

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@therealwolf/utopian-registration-backend-social-login-with-github-facebook-and-linkedin">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,