vendredi 29 juillet 2016

Laravel angular2-jwt template requests

I've an interesting question. I have setup a project using Laravel 5 and Angular2 with angular2-jwt. Laravel uses a JWT authentication library (http://ift.tt/1GFm4Yr) and produces tokens upon login, which are then sent over the vast Internet and saved to localStorage.setItem('id_token', response.token) the local machine.

Everything is working fine, but my Laravel controllers use jwt.auth, which requires my Angular2 component template requests to send with them the token. I'm a little lost here, since I seemingly cannot integrate the angular2-jwt library into my @component: templateUrl requests.

This means that I cannot request templates that should only be visible to logged in users, because the template request doesn't contain the token and thus is not authenticated to request those templates.

Can anybody advise or give me directions?

example component that I need to request a template for from Laravel with the jwt token attached to.

@Component ({
    selector: 'app-page',
    templateUrl: '/templates/Main.base',
    directives: [
        ROUTER_DIRECTIVES,
        HeaderComponent,
        UsersComponent,
        ProductsComponent
    ]
})



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2atW8Fk
via IFTTT

Aucun commentaire:

Enregistrer un commentaire