---
title: "Simon Hamp (@simonhamp) | Hashnode"
description: "Code isn't everything. Live. Read the latest articles by Simon Hamp on Hashnode."
url: "https://hashnode.com/@simonhamp"
---

@simonhamp

# Simon Hamp

@simonhamp · Las Palmas, Gran Canaria · Joined November 2015

Code isn't everything. Live

[Website](https://simonhamp.me/)

## Comments

[There are a few things in this so I'm going to try to keep it simple: Firstly, for popular services, I highly recommend using Laravel's official OAuth client library Socialite. It makes registering and authenticating users in Laravel via external OAuth providers super easy and can easily be extended to support custom providers. This allows you to bypass the need for a password altogether and is one of the main selling points for "Social Sign-In". There's also a third-party set of integrations for the less common OAuth providers called Socialite Providers - check that out too in case you ever want to give folks another way to login. New users When you've got a new user's Facebook/Google token, you should create a new record in your users table. You can store the token with it. (Handling of tokens is a whole other topic that will need to be covered in another post perhaps, because usually these tokens expire For most services (Facebook/Google etc), their API exposes a secure endpoint (you will need to send the token for the user in the request) that lets you grab a few basic details about the user, such as the name and email address they use on that service. Depending on the scopes requested and the legal agreements in place, you may be allowed to store these details along with the user's record in your own database. What you absolutely MUST store here is their unique ID for that service as this is what will allow you to determine whether a user is signing in or registering via a given service. So for example, in your users table, you should have a separate column for each service, like google\_user\_id, facebook\_user\_id. (Don't forget to index those columns too!) Now you have some choices to make: it's quite common that a user will forget that they signed up for your service using a particular social account, especially if you have many options available - I've done it myself, forgotten which social network I used to sign up for another app/site. It can be a bit disconcerting for the user (and annoying for you as the developer/business owner) if they inadvertently choose a different option to the one they used before, only to find that it creates a completely new account instead of logging them in to the account they originally created. In this case, it's good to try and find a way of matching users up across their different social logins - their email address may be a good candidate for this. You could also give your users a back-up option by allowing them to set a password directly in your system. This is useful in case any of the third-party login providers you've integrated with become inaccessible from your system or for the user for any reason (e.g. they go down or your integration breaks because of API or SDK changes). If you do choose to let social sign-in users set a password too, you should probably think about doing this in your on-boarding flow right after they've registered and making it mandatory so that they can't skip it even if they go away and come back later. Existing users Of course, it's best not to forget about people who originally chose to sign up with a password. Seeing social sign-in options available, they may now wish to add these methods to their existing account to make their future logins easier. This requires a little more thought: should they login with their password first and then gain access to tools to link these accounts? Or can they attempt to sign in and you try to find their account based on the email address? How will you handle weird edge cases where the email address for a social sign-in matches the wrong account? You will probably want some out-of-band verification, e.g. an email with a one-time unique code to prove ownership. There's no right answers here as it depends largely on your users, the networks they're more likely to have accounts on and the ones you're prepared to support. Please keep in mind that I've used the words "you" and "your" a lot here for simplicity, but in this case some of this really applies to your client, as legally speaking it is about their relationship with their users and the social sign-in providers they want to use. Happy to try and help further as time permits.](https://hashnode.com/forums/thread/how-the-flow-of-user-authentication-will-be-implemented-when-using-oauth-openid-like-facebook-and-google-with-our-own-login-system/comment/5b2a38aaa55b15344033edab)

Comment · Thread · Jun 20, 2018 · [How the flow of user authentication will be implemented when using oauth +openID like facebook and google with our own login system?](https://hashnode.com/forums/thread/how-the-flow-of-user-authentication-will-be-implemented-when-using-oauth-openid-like-facebook-and-google-with-our-own-login-system)

[Ensemble - A web app (and Composer package) that helps you to stay on top all of your app's Composer dependencies](https://hashnode.com/forums/thread/did-you-find-or-create-something-cool-june-2018/comment/5b1fa5a2be5daef9113b135e)

Comment · Thread · Jun 12, 2018 · 2 · [Did you find or create something cool? (June, 2018)](https://hashnode.com/forums/thread/did-you-find-or-create-something-cool-june-2018)

[Great review, Yos. Thanks for sharing!](https://hashnode.com/posts/stateless-authentication-with-json-web-tokens/5ab9e12ba484280566336f9c/comment/5abcc45164eb7f4e5fe25a07)

Comment · Article · Mar 29, 2018 · [Stateless Authentication with JSON Web Tokens](https://hashnode.com/posts/stateless-authentication-with-json-web-tokens/5ab9e12ba484280566336f9c)

[This is fine if the string you're dealing with includes the MIME type at the start, but don't bank on it. It's more likely that the Base64-encoded file string won't include that as it's not part of the encoding process and won't be added by default. It might be added after the fact though, for example as a part of the HTML for rendering on a page. The MIME type prefix is required by browsers to aid in rendering Base64-encoded image files.](https://hashnode.com/forums/thread/how-do-you-validate-a-base64-image/comment/5a5c955f534a2f560ab0a597#reply-5a5f81cfaf83bc5d36e60a9e)

Reply · Thread · Jan 17, 2018 · [How do you validate a base64 image?](https://hashnode.com/forums/thread/how-do-you-validate-a-base64-image)

[Although this isn't a very popular opinion, I've found Lumen to be really great to build an API with. It's very light and I haven't come up against any problems when trying to create a fairly complex API. There's nothing in there that I've thought "Oh damn! We should be using a full-blown Laravel installation." Admittedly, it is missing a couple of features that you might be used to if you're familiar with Laravel, but if you don't mind simplifying/separating some stuff out (i.e. OAuth in a separate service OR just using API keys, for example) and writing a little bit of piping, you can achieve great things. The performance of Lumen is great for our needs and we've managed to create a really flexible and efficient API with it that conforms to the JSON-API standard, uses OAuth for access delegation and much more, without tying us to a particular package. I'd be happy to go into more detail separately about some of the things we've done to make this work well.](https://hashnode.com/forums/thread/building-an-api-with-laravel/comment/5a44c5f5b5edf0cd7d724959)

Comment · Thread · Dec 28, 2017 · [Building an API with Laravel](https://hashnode.com/forums/thread/building-an-api-with-laravel)

[Thanks for sharing, John! :)](https://hashnode.com/forums/thread/remoteartisan-a-way-to-call-another-laravellumen-applications-artisan-command-from-the-context-of-the-current-application/comment/5a3d4ea291da8e7a4d3addef)

Comment · Thread · Dec 22, 2017 · [RemoteArtisan: A way to call another Laravel/Lumen application's artisan command from the context of the current application.](https://hashnode.com/forums/thread/remoteartisan-a-way-to-call-another-laravellumen-applications-artisan-command-from-the-context-of-the-current-application)

[Just because some users of a thing are "poor coders" doesn't mean you shouldn't use it. By that logic, you should never use your operating system. It's also a massive opportunity to help them become better coders... even if that means helping them move to tools other than jQuery.](https://hashnode.com/forums/thread/why-do-many-web-developers-hate-jquery/comment/59a2190378bcbcd624bf6e6e#reply-59a82a9d4f8975150efb566a)

Reply · Thread · Aug 31, 2017 · [Why do many web developers hate jQuery?](https://hashnode.com/forums/thread/why-do-many-web-developers-hate-jquery)

[As Taylor says repeatedly: read the docs! They are a great resource and perhaps overlooked. It's not always clear why or when you might use a specific feature, but almost everything is covered in enough detail to get you started and digging deeper. Beyond that, as others have suggested, there's the API documentation/framework source, which will enlighten take you to the next level when the docs aren't quite enough.](https://hashnode.com/forums/thread/wherehow-is-the-best-placeway-to-learn-laravel/comment/592c5a0c0b66811011a13120)

Comment · Thread · May 29, 2017 · [Where/how is the best place/way to learn Laravel?](https://hashnode.com/forums/thread/wherehow-is-the-best-placeway-to-learn-laravel)

[Agreed. My ego was saying "delete the post and remove all traces", but I think it's actually more valuable to me (and maybe others) if I just leave this here.](https://hashnode.com/posts/a-little-trick-with-eloquent-query-scopes-that-makes-them-super-reusable/5890be485478d2f4f656800e/comment/5891cef0cfe48c4f6b113b48#reply-5898d5230ff2cedd1c336e2a)

Reply · Article · Feb 6, 2017 · 2 · [A little trick with Eloquent query scopes that makes them super reusable](https://hashnode.com/posts/a-little-trick-with-eloquent-query-scopes-that-makes-them-super-reusable/5890be485478d2f4f656800e)

[This is actually very incorrect Well, no, it wasn't incorrect, it just wasn't as specific as you correctly note. I completely agree with your summation and I'll concede to anyone who knows far more about the inner workings of Eloquent than me. Indeed, that is how I'd hoped things would work. However, when I tried to get this to work originally I was getting a Object of class Illuminate\\Database\\Eloquent\\Relations\\HasMany could not be converted to string error for some reason. I hadn't explored this error to find out what was causing it. But it seems that was because of the lack of a return. After @dbw 's comment, I added the return and tried again, but I was still getting an error. I can only assume that I attempted this so hastily that I didn't spot another error. Following your comment, I've tried this code again and I am now getting the desired result. I hang my head in shame and bow to your greatness. Clearly, I need to fact-check my stories more thoroughly in future! Thank you for taking the time to write a considered response.](https://hashnode.com/posts/a-little-trick-with-eloquent-query-scopes-that-makes-them-super-reusable/5890be485478d2f4f656800e/comment/5891cef0cfe48c4f6b113b48#reply-5894532a1854daa217ca56d8)

Reply · Article · Feb 3, 2017 · 2 · [A little trick with Eloquent query scopes that makes them super reusable](https://hashnode.com/posts/a-little-trick-with-eloquent-query-scopes-that-makes-them-super-reusable/5890be485478d2f4f656800e)
