Ionic AuthService or login providers

Hi,

I’m trying to create a simple login page in an ionic app to connect to a custom laravel website (which uses the standard boilerplate laravel 4.4 auth class). I can see quite a few old tutorials dotted about the web suggesting using various things which were built into the @native apps but which don’t seem to be there now. Specifically AuthService. Would that have been suitable, does it still exist and if not is there a replacement method to use?

I’ve found a cordova app called satellizer which might do the job, but equally i’m at a slight loss as to how to use this with an ionic app because the instructions in the satelizer readme are for a straight cordova app and not knowing ionic 3 that well, i don’t really know how to implement it. Does anyone have any tips?

Why do you need Cordova anything? Can’t you just talk to laravel with Angular http? Stateless http authentication. Either I’m missing something, or this is a lot simpler than you’re making it. Right now, I’m not sure which is true.

It could definitely be simpler than I think! I was following the guide below that suggested it needed satellizer to allow login functionality. I’m probably being a bit dumb with it but it doesn’t seem to match with ionic 3 and looks like it’s for an ionic 1 app.

AngularJS (Angular 1, Ionic v1) and Angular (Angular 2+, Ionic 2+) are completely fundamentally incompatible. If you are trying to build a modern app, you are best off totally ignoring anything you stumble across on the internet that is talking about v1 things, and that includes everything you have mentioned in this thread.

It is not particularly challenging (literally less than 10 lines of code for a simple fully functioning implementation), and may in fact be a valuable learning exercise, to roll your own token storage and interceptor system.

If you want to go with an existing solution, one that seems to be fairly widely used (although I have no direct experience with it) is angular2-jwt. Pay careful attention to the versions, because there is one for Angular 2-4.2, another for 4.3-5 (the one you want for Ionic 3), and a third for 6+ (the one you would want for Ionic 4).

1 Like

Thanks, I’ll have a look. I was coming to the same conclusion. I’m new to Angular, Ionic and pretty much apps in general too so it’s all good fun!