@@ -3,9 +3,12 @@ const { existsSync, readdirSync } = require('fs')
3
3
const merge = require ( 'lodash/merge' )
4
4
const uniq = require ( 'lodash/uniq' )
5
5
const defaults = require ( './defaults' )
6
+ const consola = require ( 'consola' )
6
7
7
8
const libRoot = resolve ( __dirname , '..' )
8
9
10
+ const logger = consola . withScope ( 'nuxt:auth' )
11
+
9
12
module . exports = function ( moduleOptions ) {
10
13
// Merge all option sources
11
14
const options = merge ( { } , defaults , moduleOptions , this . options . auth )
@@ -24,7 +27,7 @@ module.exports = function (moduleOptions) {
24
27
if ( ! options . defaultStrategy && strategies . length ) {
25
28
options . defaultStrategy = strategies [ 0 ] . _name
26
29
} else {
27
- console . warn ( 'no strategy defined!' )
30
+ logger . warn ( 'no strategy defined!' )
28
31
}
29
32
30
33
// Copy plugin
@@ -34,10 +37,7 @@ module.exports = function (moduleOptions) {
34
37
function validateOptions ( options ) {
35
38
if ( options . endpoints ) {
36
39
// eslint-disable-next-line no-console
37
- console . error (
38
- '[DEPRECATED] [AUTH] ' +
39
- '`auth.endpoints` has been moved into `auth.strategies.local`.'
40
- )
40
+ logger . error ( '`auth.endpoints` has been moved into `auth.strategies.local`.' )
41
41
options . strategies . local = merge ( { } , options . strategies . local , {
42
42
endpoints : options . endpoints
43
43
} )
@@ -46,10 +46,7 @@ function validateOptions (options) {
46
46
47
47
if ( options . watchLoggedIn ) {
48
48
// eslint-disable-next-line no-console
49
- console . error (
50
- '[DEPRECATED] [AUTH] ' +
51
- '`watchLoggedIn` has been deprecated. Use `redirect.logout` instead.'
52
- )
49
+ logger . error ( '`watchLoggedIn` has been deprecated. Use `redirect.logout` instead.' )
53
50
if ( options . watchLoggedIn === false ) {
54
51
options . redirect . logout = false
55
52
}
@@ -58,10 +55,7 @@ function validateOptions (options) {
58
55
59
56
// Enforce vuex store because auth depends on it
60
57
if ( ! this . options . store ) {
61
- throw new Error (
62
- '[ERR] [AUTH] ' +
63
- 'Enable vuex store by creating `store/index.js`.'
64
- )
58
+ logger . fatal ( 'Enable vuex store by creating `store/index.js`.' )
65
59
}
66
60
}
67
61
0 commit comments