![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ts.corals.io/frontend/.nuxt/ |
import Middleware from './middleware' import { Auth, authMiddleware, ExpiredAuthSessionError } from '~auth/runtime' // Active schemes import { LocalScheme } from '~auth/runtime' Middleware.auth = authMiddleware export default function (ctx, inject) { // Options const options = { "resetOnError": false, "ignoreExceptions": false, "scopeKey": "scope", "rewriteRedirects": true, "fullPathRedirect": false, "watchLoggedIn": true, "redirect": { "login": "/login", "logout": "/", "home": "/", "callback": "/login" }, "vuex": { "namespace": "auth" }, "cookie": { "prefix": "auth.", "options": { "path": "/" } }, "localStorage": { "prefix": "auth." }, "defaultStrategy": "local" } // Create a new Auth instance const $auth = new Auth(ctx, options) // Register strategies // local $auth.registerStrategy('local', new LocalScheme($auth, { "endpoints": { "login": { "url": "auth/login", "method": "post" }, "logout": { "url": "auth/logout", "method": "post" }, "user": { "url": "profile", "method": "get" } }, "user": { "property": "data" }, "token": { "property": "data.authorization", "required": true, "type": "" }, "name": "local" })) // Inject it to nuxt context as $auth inject('auth', $auth) ctx.$auth = $auth // Initialize auth return $auth.init().catch(error => { if (process.client) { // Don't console log expired auth session errors. This error is common, and expected to happen. // The error happens whenever the user does an ssr request (reload/initial navigation) with an expired refresh // token. We don't want to log this as an error. if (error instanceof ExpiredAuthSessionError) { return } console.error('[ERROR] [AUTH]', error) } }) }