Welcome Guest, Not a member yet? Register   Sign In
CI4 as backend for React.js and authentication
#8

(This post was last modified: 03-29-2022, 02:24 AM by ignitedcms.)

I haven't used shield or myth:auth per se, but essentially I'm planning to work on something similar.

As React is considered a Single Page App, the way you perform authentication is quite different from your standard PHP app as everything needs to persist as you perform javascript client side routing.

If you store the JWT in session storage you can just use regular javascript to inspect the token and use that to validate the controllers I believe, it is something I plan to integrate into my own backlog at some point.

What I'd also recommend getting (when it is on sale) is picking up this course as it hand holds you through the entire process in React.

https://www.udemy.com/course/react-the-c...ncl-redux/

The only thing I would add to it, is you would want to use State management of sorts to make it easier to transfer login auth across your app, or the contextAPI.

Some of my favourite state management solutions for React are probably 'Recoil' and 'Zustand'

But if you have no concerns about Javascript framework popularity - 'Svelte' is the clear winner for me in terms of simplicity.

Last time I checked I don't think shield has a JWT auth although I didn't look at it for long. You most probably want to pull in a dependency. This tutorial looks decent enough, although I haven't fully interrogated it for security issues.

https://mfikri.com/en/blog/codeigniter-login-jwt

Also one more thing to add, as React out of the box doesn't have SEO, it would be sensible to get it working with something like 'nextjs' from the get go.

As you can see, the combination of all the above steps make it super difficult to maintain effectively.

My personal recommendation, is to forgo all the above and just use a PHP stack with a decent JS library (vuejs or petitevue or even alpinejs) pulled in from a CDN for the front end, as in the majority of cases you'll find the insanity of a full Javascript frontend isn't even warranted.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply


Messages In This Thread
RE: CI4 as backend for React.js and authentication - by ignitedcms - 03-29-2022, 12:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB