1.0.0 • Published 4 years ago
next-local-auth v1.0.0
next-local-auth
An auth plugin for Next.js with acces token and refresh token
API Client
Import
import * as $auth from "next-local-auth"
import { $axios } from "next-local-auth"
Init in _app.py
// Init lib in _app.py
$auth.init("domain", token_time, refresh_time)
$auth.init("/ || https://xxx.xxxx.xx/", 60*60*2, 60*60*24*30) // access_tonken: 2h, refresh_token: 30days
All functions
// Login
$auth.login("email", "password")
// Logout
$auth.logout()
// isLoggedIn
$auth.isLoggedIn() // return true or false
// Get Profile
$auth.getProfile() // return the profile
// Request the Profile after a changement
$auth.requestProfile
// $axios
It's an axios instance that's authenticated.
$axios.get().then()
Backend
You need to implement this routes:
- .../login/ => return "access_token" & "refresh_token"
- .../profile/ => return a json of data
- ... = domain give on init()
1.0.0
4 years ago