Skip to content

Commit d694480

Browse files
authored
Merge pull request dsb-norge#39 from wirk/master
dsb-norge#31: add onAuthRefreshError callback
2 parents 62357b8 + d50db4f commit d694480

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ function init (config, watch, options) {
9191
keycloak.onAuthRefreshSuccess = function () {
9292
updateWatchVariables(true)
9393
}
94+
keycloak.onAuthRefreshError = function () {
95+
updateWatchVariables(false)
96+
typeof options.onAuthRefreshError === 'function' && options.onAuthRefreshError.bind(this, keycloak)()
97+
}
9498
keycloak.init(options.init)
9599
.error(err => {
96100
typeof options.onInitError === 'function' && options.onInitError(err)
@@ -130,7 +134,7 @@ function init (config, watch, options) {
130134
}
131135

132136
function assertOptions (options) {
133-
const {config, init, onReady, onInitError} = options
137+
const {config, init, onReady, onInitError, onAuthRefreshError} = options
134138
if (typeof config !== 'string' && !_isObject(config)) {
135139
return {hasError: true, error: `'config' option must be a string or an object. Found: '${config}'`}
136140
}
@@ -143,6 +147,9 @@ function assertOptions (options) {
143147
if (onInitError && typeof onInitError !== 'function') {
144148
return {hasError: true, error: `'onInitError' option must be a function. Found: '${onInitError}'`}
145149
}
150+
if (onAuthRefreshError && typeof onAuthRefreshError !== 'function') {
151+
return {hasError: true, error: `'onAuthRefreshError' option must be a function. Found: '${onAuthRefreshError}'`}
152+
}
146153
return {
147154
hasError: false,
148155
error: null

0 commit comments

Comments
 (0)