Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nuxtjs/auth

Package Overview
Dependencies
Maintainers
3
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxtjs/auth - npm Package Compare versions

Comparing version 4.0.0-rc.0 to 4.0.0-rc.1

lib/templates/auth.utilities.js

16

CHANGELOG.md

@@ -5,2 +5,18 @@ # Change Log

<a name="4.0.0-rc.1"></a>
# [4.0.0-rc.1](https://github.com/nuxt-community/auth-module/compare/v4.0.0-rc.0...v4.0.0-rc.1) (2018-02-03)
### Bug Fixes
* **deps:** update dependencies ([5d6cb8a](https://github.com/nuxt-community/auth-module/commit/5d6cb8a))
* **watcher:** close [#52](https://github.com/nuxt-community/auth-module/issues/52) and undefined bug ([2a03f2f](https://github.com/nuxt-community/auth-module/commit/2a03f2f))
### Features
* watchState and watchLoggedIn ([b628455](https://github.com/nuxt-community/auth-module/commit/b628455)), closes [#52](https://github.com/nuxt-community/auth-module/issues/52)
<a name="4.0.0-rc.0"></a>

@@ -7,0 +23,0 @@ # [4.0.0-rc.0](https://github.com/nuxt-community/auth-module/compare/v3.4.1...v4.0.0-rc.0) (2018-02-02)

1

lib/defaults.js

@@ -5,2 +5,3 @@ module.exports = {

rewriteRedirects: true,
watchLoggedIn: true,
namespace: 'auth',

@@ -7,0 +8,0 @@ scopeKey: 'scope',

@@ -43,2 +43,9 @@ const { resolve, join } = require('path')

// Utilities
this.addTemplate({
src: resolve(__dirname, './templates/auth.utilities.js'),
fileName: 'auth/auth.utilities.js',
options
})
// Class

@@ -45,0 +52,0 @@ this.addTemplate({

26

lib/templates/auth.class.js
import Cookies from 'js-cookie'
import { parse as parseCookie } from 'cookie'
import { routeOption } from './auth.utilities'
import getProp from 'dotprop'

@@ -25,2 +26,7 @@ import Vue from 'vue'

// Watch for loggedIn changes only in client side
if (this.options.watchLoggedIn && process.browser) {
this._watchLoggedIn()
}
this._registerVuexStore()

@@ -54,11 +60,12 @@ }

watchLoggedIn () {
_watchLoggedIn () {
this._loggedInWatcher =
this._loggedInWatcher ||
this.$store.watch(
state => state[this.options.namespace]['loggedIn'],
() => {
this.redirect('home')
this.watchState('loggedIn', () => {
if (routeOption(this.$route, 'auth', false)) {
return
}
)
this.redirect('home')
})
return this._loggedInWatcher

@@ -143,2 +150,9 @@ }

watchState (key, fn) {
return this.$store.watch(
state => getProp(state[this.options.namespace], key),
fn
)
}
setLocalStorage (name, value) {

@@ -145,0 +159,0 @@ if (typeof localStorage !== 'undefined') {

import Middleware from '../middleware'
import { routeOption } from "./auth.utilities";

@@ -23,15 +24,1 @@ Middleware.auth = function (ctx) {

}
// Utility to get route option
function routeOption (route, key, value) {
return route.matched.some(m => {
// Browser
if (process.browser) {
return Object.values(m.components).some(component => component.options[key] === value)
}
// SSR
return Object.values(m.components).some(component =>
Object.values(component._Ctor).some(ctor => ctor.options && ctor.options[key] === value)
)
})
}

@@ -20,7 +20,2 @@ import './auth.middleware'

// Watch for loggedIn changes only in client side
if (process.browser) {
$auth.watchLoggedIn()
}
// Fetch user if is not available

@@ -27,0 +22,0 @@ if (!$auth.state.user) {

{
"name": "@nuxtjs/auth",
"version": "4.0.0-rc.0",
"version": "4.0.0-rc.1",
"description": "Authentication module for Nuxt.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -134,2 +134,5 @@ <h1 align="center">🔑 Auth</h1>

// Watch state changes
this.$auth.watchState('loggedIn', newValue => { })
// Cookie

@@ -169,5 +172,3 @@ this.$auth.setCookie(key, val, options)

export default {
options: {
auth: false
}
auth: false
}

@@ -264,2 +265,8 @@ ```

### `watchLoggedIn`
* Default: `true`
If enabled, user will automatically redirected to `redirects.home` after login/logout.
### `namespace`

@@ -266,0 +273,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc