Skip to content

Instantly share code, notes, and snippets.

View donmbelembe's full-sized avatar

donmbelembe

  • Kinshasa, DRC
View GitHub Profile
{
"basics": {
"name": "Don Mbelembe",
"label": "Programmer",
"picture": "",
"email": "[email protected]",
"phone": "+243 904094051",
"website": "",
"summary": "Passionate Software Engineer with more than 4 years of professional experience building web applications. Excelling in full-stack development, particularly the Laravel (PHP) + Vue.js stack and Python language.",
"location": {
@donmbelembe
donmbelembe / blog.md
Created September 26, 2018 08:00 — forked from JacobBennett/blog.md
API Token Authentication in Laravel 5.2 & 5.3

I recently had the need to write a small url shortening application. I am aware that this problem has been solved quite a few times before, but what is being a developer if not reinventing the wheel just for the heck of it? Custom CMS anyone?

Knowing that this was going to be a tiny RESTful API and also knowing that Laravel 5.2 had API rate limiting built in, I was eager to give it a try. Taylor Otwell being Taylor Otwell shipped 5.2 with the rate limiting defaults set up out of the box and I had my application building out short url's in a matter of minutes. The problem for me came when I wanted to start associating those short urls with a user.

Typically my applications have a UI and authentication is done through a simple login page. Obviously for a RESTful API, having a login page isn't ideal. Instead, my hope was to have users append an api_token to the end of their query string and use that to auth

@donmbelembe
donmbelembe / gist:cbf5aa11c301754eb0e5029adb0973e8
Created November 2, 2017 07:17 — forked from jrmadsen67/gist:bd0f9ad0ef1ed6bb594e
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
<div class="..." v-dragscroll>
...
</div>
<div class="..." v-dragscroll:nochilddrag>
...
</div>