[WP] 19.02.2023 | auth-intro

fig 1.1 JWT structure


 ----------------------------------------------------------------------

For the last two days i was rather working on stuff other than react. In this post i will list these things. I will start from short info that localhost is an alias for local adress 127.0.0.1. O-ther thing is about form submit handling. In php form submitted data is wirtten in form-url endcoded format. It is similar to JSON(application/json). For some time i was dwelling for a way to make react app routes private/public and grant access depending on if User has valid token within his local storage. Adittionaly all requests need to contain token as a value of authentication field of header to be successfully procesed.


Current PP frontend react app views would divide as this. Public routes : home route, login route, register route, password reset route. Private routes: search, my Competences, User Roles, User profile. Solution divides into two part client-side solution and server side access auth. I found info about JWT – json web tokens.


React elements should have single source of truth. One of recognised time-related library of JS is date fns which contains method such as format which allows to specify format for date & time info displayed.


----------------------------------------------------------

Update:


Values of state variables used within useEffect hook make become stale with time. There are two ways to handle this problem. The former is to specify a piece of state within useEffect hook dependency array. The latter way is to pass a cb function within state setter. In such case react will provide a fresh state related value within arrow function arguments and may be used within instruction block.

In one of the exercises event bubling revision was done, event.code field was used(is specifies clicked key for ‚key down’ events. event.stopPropagation() method used on any DOM node limits further event bubbling.


Ready to roll

g-marcin

Komentarze

Popularne posty z tego bloga

[WP] 23.06.2023 | subjects

15.07.2024 | simplicity

[WP] 05.06.2023 | angular-intro