User Authentication with Laravel 5 and EmberJS (CLI)

Hello everybody,

In advanced my apologies for my broken English.

Lately I’m trying to learn EmberJS with the CLI.
For now I have a basic understanding how to set up a project, handle routes, errors, models.

I would like to learn how to handle user authentication.

On the backend I will be using Laravel 5. I have quite some experience with Laravel and in the past created single page apps with authentication using Backbone.

In the past with Backbone I use to send the login to a Larevel endpoint and then retrieve a JWT which I added to the $.ajax headers.

After googling the topic I found: Ember Simple Auth
But no examples how to implement this with Laravel.

Can anybody give or point me to an working example how to set up this authentication?

This is what I’m using.

I’m also using this to deal with CORS since the rest server and client facing application are on separate domains.

Hello oddz,

Thank you for your fast reply.

I’ve been using the JWT implementation of Auth0. And the same CORS package as you recommend.

Can you give an example on how the login controller and a protected (REST) route in Laravel would look and an example on how to access these with Ember?

Here is an example of my Laravel authorization controller.

<?php namespace Foo\Http\Controllers\Api;

use Request;
use Response;
use JWTAuth;
use Input;
use Foo\Http\Requests;
use Foo\Http\Controllers\Controller;

class ApiAuthController extends Controller {

     * Get token.
    public function token() {

        $credentials = Request::only('email', 'password');

        if ( ! $token = JWTAuth::attempt($credentials) )

        return Response::json(['data'=> $token])->setCallback(Request::input('callback'));


     * Expire token.
    public function expire() {



As for the Ember side of things I’m using Angular and not familiar with Ember. What you would need to do through is make a http request in ember to the route associated with the authorization controller. I than use local storage to store the token and send it for every request to the rest api.

Thank you for taking the time to show this example.

I’ve got a working authentication with Ember and Laraval using JWT.

I’ve used on the backend (thanks for the tip!) set it up using the wiki on github together with the barryvdh cors package.

I’ve found this (ember-cli-simple-auth-token) extension for Ember. It fits nicely together.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.