react-auth-component
npm install react-auth-componentbash
npm install --save react-auth-component
`
Usage
This is a simple manager of login & registration with JWT json web token, is good to use if you want to create a login very fast just to start your application.
IMPORTANT!:
In the Example behind the api rest the you are calling expect a Json with field called 'jwt'. If you have a different name put in : tokenName="yournameTokenJson"
EXAMPLE of json that you can receive:
{
"yournameTokenJson": "eyJhbGcinometokencasualJH6omU",
"id": 12,
}
if as a response it has a String it will be showd as message in red
`jsx
import React, { Component } from 'react'
import { Route, Link, Routes } from 'react-router-dom';
import Home from '../page/home';
import About from '../page/notFound';
import { Auth } from 'react-auth-component'
import 'react-auth-component/dist/index.css'
class Example extends Component {
render() {
<>
} />
} />
exact
path="/"
element={
PageAuthenticated="home"
urlRegister="http://example.com/api/auth/register"
urlLogin="http://example.com/api/auth/login"
tokenServerName="jwt"
/>
}
/>
>
}
}
const App = () => {
return (
);
};
``