1.0.21 • Published 5 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-autenticacao
Como 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-token
import 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
5 years ago
1.0.20
5 years ago
1.0.19
5 years ago
1.0.18
5 years ago
1.0.17
5 years ago
1.0.16
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.13
5 years ago
1.0.12
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago