@kenetto/kenetto-redux-authenticator
v0.0.2
Published
## Usage
Downloads
6
Readme
Kenetto-Redux-Authenticator
Usage
Install kenetto-redux-authenticator via npm.
npm install --save @kenetto/kenetto-redux-authenticator
Import the necessary components
import Auth from '@kenetto/kenetto-redux-authenticator'
import {Authenticator} from '@kenetto/kenetto-redux-authenticator'
Create the configurationAuth0
with the necessary credentials. This should come from the environment variables.
The configuration must include domain, clientID, responseType, audience, scope and returnURI
Create an instance of the Auth
class, which you will use for authentication.
const auth = new Auth(configurationAuth0, configurationBaseName, configurationNameSpace)
Use the auth.isAuthenticated()
to check if user is authenticated. The function returns a boolean
with the result.
Use the auth.logout()
method to logout. The method should receive a function which will push the next page path.
auth.logout()
Use the auth.login(redirectURI)
to login and redirect to pretended web page which needs to be passes to the method as a property.
auth.login('/example')
Use auth.getProfile()
to get the profile of the currently logged user.
auth.getProfile().then(profile => {
...
})