1.0.21 • Published 6 years ago
mio-library-autenticacao v1.0.21
mio-library-autenticacao
Componente React para login
Instalação
//npm
npm install --save mio-library-autenticacao
//yarn
yarn add mio-library-autenticacaoComo utilizar
Você deve definir os seguintes parâmetros de configuração no arquivo .env
REACT_APP_ID=app-id-example
REACT_APP_MIO_AUTH_API_URL=http://urlofauthentication.com:3000
REACT_APP_MIO_AUTH_TOKEN=persist:@mio-template:jwt-tokenimport React, { Component } from "react";
import { Autenticacao } from "mio-library-autenticacao";
const Example = props => {
return (
<Autenticacao
beforeSubmit={() => {
// do something before submitting the login form
}}
afterSubmit={result => {
/*
* Do something after submitting the login form.
* result is a json that can contain three attributes
* {
* status: <boolean>
* message: <string> in case status is false message is undefined
* error: <string> in case status is true error is undefined
* }
*/
/*
* Example, you can redirect page if login is succefully
*/
if (result.status) {
props.history.push("/home");
}
}}
/>
);
};
export default Example;Api
<Autenticacao />
The component accepts the following props:
| Name | Type | Description |
|---|---|---|
| onSubmit | function | Sobrescreva está função caso queira utilizar seu próprio método de autenticação. (e, email, password) => { //faça algo } |
| beforeSubmit | function | Função callback que é disparada antes do envio de formulário de login. |
| afterSubmit | function | Função callback que é disparada antes do envio de formulário de login. |
Helpers
mio-library-autenticacao provides auxiliary methods
| Name | Return | Description |
|---|---|---|
| isAuthenticated | boolean | retorna se o usuário está autenticado ou não |
| getToken | string | A token jwt salca no local storage |
| getData | json | extrai os dados da token jwt |
| logout | void | faz o logout do usuário |
License
MIT © raphaelbsr
1.0.21
6 years ago
1.0.20
6 years ago
1.0.19
6 years ago
1.0.18
6 years ago
1.0.17
6 years ago
1.0.16
6 years ago
1.0.15
6 years ago
1.0.14
6 years ago
1.0.13
6 years ago
1.0.12
6 years ago
1.0.11
6 years ago
1.0.10
6 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago