Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seasonedcc/croods-auth
A ready-to-use solution for user authentication and permission control
https://github.com/seasonedcc/croods-auth
Last synced: about 1 month ago
JSON representation
A ready-to-use solution for user authentication and permission control
- Host: GitHub
- URL: https://github.com/seasonedcc/croods-auth
- Owner: seasonedcc
- Created: 2019-04-30T02:21:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T04:10:05.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T20:40:14.962Z (2 months ago)
- Language: JavaScript
- Homepage: https://croods.netlify.com/docs/cauth-intro
- Size: 5.46 MB
- Stars: 0
- Watchers: 23
- Forks: 1
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Maintainability](https://api.codeclimate.com/v1/badges/f37c434f6b6e73e2d050/maintainability)](https://codeclimate.com/github/SeasonedSoftware/croods-auth/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/f37c434f6b6e73e2d050/test_coverage)](https://codeclimate.com/github/SeasonedSoftware/croods-auth/test_coverage)
![npm bundle size](https://img.shields.io/bundlephobia/min/croods-auth)# Croods-Auth
Croods-auth is another layer of abstraction on top of Croods, providing you with a ready-to-use solution for user authentication and permission control.
## Install
```bash
yarn add croods-auth croods react react-dom lodash react-use-form-state
```## Usage
Bellow is a simple example of its usage with @reach/router:
```js
import { CroodsProvider } from 'croods'
import { Auth, authHeaders, saveHeaders } from 'croods-auth'export default props => (
redirect('/sign-in')}
/>
)
```Main concepts to notice here:
- **authHeaders:** Provides Croods with headers from the storage for usage on Croods requests. Eg.: Auth-Token, Uid, Client, Token-Type and Expiry.
- **Auth:** Used for checking permissions required for a component.And then we implement our SignIn page:
```js
import { useSignIn } from 'croods-auth'const Input = ({ name, label = name, ...props }) => (
{label}
)export default props => {
const [{ signingIn, error, ...config }] = useSignIn({
afterSuccess: () => navigate(`/home`),
})
return (
Sign In
{signingIn ? 'Signing in...' : 'Sign in'}
)
}
```There are hooks available for all usual authentication operations (sign up, edit profile, etc).
Read more about it [on the Docs](https://croods.netlify.com/docs/cauth-intro)!