# |
Dec 29th 2018, 16:04 |
itmpls |
that's what I do |
# |
Dec 29th 2018, 16:02 |
challgren |
https://github.com/CakeDC/users/blob/master/src/Controller/Traits/LoginTrait.php |
# |
Dec 29th 2018, 16:01 |
challgren |
Or just use your own custom controllers and the traits provided |
# |
Dec 29th 2018, 16:01 |
NickBusey |
Alright, well I'll submit a pull request to CakeDC/users to remove the part where they say they support APIs |
# |
Dec 29th 2018, 16:00 |
challgren |
Yeah maybe not relying on CaekDC/users controllers might be a solution for @nickbusey |
# |
Dec 29th 2018, 16:00 |
admad |
@challgren then might be good idea to not use it if can't be disabled :) |
# |
Dec 29th 2018, 15:59 |
NickBusey |
Yea, I've been going through that. I have JWT working with the other resources |
# |
Dec 29th 2018, 15:59 |
admad |
NickBusey: http://www.bravo-kernel.com/2015/04/how-to-add-jwt-authentication-to-a-cakephp-3-rest-api/ |
# |
Dec 29th 2018, 15:59 |
NickBusey |
Martin`: Yup! |
# |
Dec 29th 2018, 15:58 |
challgren |
@admad CakeDC/users enables its https://github.com/CakeDC/users/blob/master/src/Controller/AppController.php#L32 |
# |
Dec 29th 2018, 15:58 |
Martin` |
NickBusey: ok, so nicest is to build something like remember but with fallback to cache when callable returns false :P |
# |
Dec 29th 2018, 15:57 |
admad |
The fact that it is looking for _Token means you do have it enabled |
# |
Dec 29th 2018, 15:57 |
NickBusey |
All the rest of my API works, user api fails |
# |
Dec 29th 2018, 15:57 |
NickBusey |
I'm not? I have disabled them both |
# |
Dec 29th 2018, 15:57 |
admad |
Nor csrf component/middleware |
# |
Dec 29th 2018, 15:56 |
admad |
Don't use securitysecomponent for api |
# |
Dec 29th 2018, 15:56 |
challgren |
@admad https://cakesf.slack.com/archives/C053DPNGT/p1546097289329500 |
# |
Dec 29th 2018, 15:56 |
NickBusey |
I have disabled the Security component, but it seems to be used anyway for the CakeDC/users login function |
# |
Dec 29th 2018, 15:55 |
NickBusey |
Because when I submit the login form, I get errors about missing _Token's, and csrf protection |
# |
Dec 29th 2018, 15:55 |
admad |
NickBusey: "I should 100% be able to present a native login screen in whatever client type I am working with, submit a request, and get a token back" what's preventing you from doing that? |
# |
Dec 29th 2018, 15:53 |
admad |
That will trigger the jsonn view being used just like it does for .json extension |
# |
Dec 29th 2018, 15:52 |
admad |
@k4t add "Accept: application/json" header to request |
# |
Dec 29th 2018, 15:52 |
NickBusey |
I should 100% be able to present a native login screen in whatever client type I am working with, submit a request, and get a token back. Having to load a webview or whatever is a hacky workaround |
# |
Dec 29th 2018, 15:52 |
NickBusey |
I don't really agree that is the issue, that is the specific problem I'm running into now, but it shouldn't be. Expecting an API client and API server to be on the same port/domain is not a reasonable assumption |
# |
Dec 29th 2018, 15:51 |
challgren |
The different ports/domains are where you run into issues |
# |
Dec 29th 2018, 15:51 |
challgren |
Cause you could log the user in with cake and then dump them into your react app and continue on |
# |
Dec 29th 2018, 15:51 |
NickBusey |
Martin`: `remember` just provides some simplicity/magic around Cache::read / Cache::write, use those directly |
# |
Dec 29th 2018, 15:50 |
challgren |
Well with the different ports that is causing your auth issues |
# |
Dec 29th 2018, 15:50 |
Martin` |
but that is not possible with remember I quess? |
# |
Dec 29th 2018, 15:50 |
NickBusey |
Well react isn't really the issue here, native apps would need the same functionality |
# |
Dec 29th 2018, 15:49 |
NickBusey |
Martin`: Sure, just add a bit in the error handler of the api request, to load specifically from the cache what you saved on the last successful request |
# |
Dec 29th 2018, 15:49 |
Martin` |
I'm using Cache::remember for that |
# |
Dec 29th 2018, 15:49 |
challgren |
Id keep asking around Im not an expert with the crud plugin and react |
# |
Dec 29th 2018, 15:48 |
Martin` |
I'm using the cache for reading data from external api's so it is not needed every request, but it is possible to fall back to cache when api request fails? |
# |
Dec 29th 2018, 15:47 |
NickBusey |
Well, sounds like Cake won't be able to do what I need it to, or at least the User plugin. Ah well, the search is on for another back end I suppose. Thanks for the help! |
# |
Dec 29th 2018, 15:44 |
NickBusey |
https://gitlab.com/NickBusey/mashio |
# |
Dec 29th 2018, 15:44 |
challgren |
Serving it from the webapp folder allows you to use cookies |
# |
Dec 29th 2018, 15:44 |
NickBusey |
And that looks almost identical to my setup |
# |
Dec 29th 2018, 15:44 |
challgren |
nm thats some old code |
# |
Dec 29th 2018, 15:44 |
NickBusey |
I'm more than open to suggestions on simplicity, but it seems like the only thing to do would be to serve the SPA from cake's webapp folder, which I may do, but doesn't really buy much during development |
# |
Dec 29th 2018, 15:43 |
challgren |
You look at https://github.com/Rubyan/CakePHP-react |