diff --git a/assets/js/plugins/KimaiAjaxModalForm.js b/assets/js/plugins/KimaiAjaxModalForm.js index fbcfc5cf..b56cdffc 100644 --- a/assets/js/plugins/KimaiAjaxModalForm.js +++ b/assets/js/plugins/KimaiAjaxModalForm.js @@ -57,12 +57,9 @@ export default class KimaiAjaxModalForm extends KimaiClickHandlerReducedInTableR if (errorHandler === undefined) { errorHandler = function(xhr, err) { - if (xhr.status !== undefined && xhr.status === 403) { - const alert = self.getContainer().getPlugin('alert'); - alert.error(xhr.statusText); - return; + if (xhr.status === undefined || xhr.status !== 403) { + window.location = url; } - window.location = url; }; } diff --git a/assets/js/plugins/KimaiThemeInitializer.js b/assets/js/plugins/KimaiThemeInitializer.js index 2149dabf..550ee2d4 100644 --- a/assets/js/plugins/KimaiThemeInitializer.js +++ b/assets/js/plugins/KimaiThemeInitializer.js @@ -15,8 +15,8 @@ import KimaiPlugin from '../KimaiPlugin'; export default class KimaiThemeInitializer extends KimaiPlugin { init() { + this.registerGlobalAjaxErrorHandler(); this.registerAutomaticAlertRemove('div.alert-success', 5000); - // activate the dropdown functionality jQuery('.dropdown-toggle').dropdown(); // activate the tooltip functionality @@ -25,6 +25,27 @@ export default class KimaiThemeInitializer extends KimaiPlugin { this.getContainer().getPlugin('form').activateForm('.content-wrapper form', 'body'); } + /** + * redirect access denied / session timeouts to login page + */ + registerGlobalAjaxErrorHandler() { + const loginUrl = this.getContainer().getConfiguration().get('login'); + const alert = this.getContainer().getPlugin('alert'); + const translation = this.getContainer().getTranslation().get('login.required'); + jQuery(document).ajaxError(function(event, jqxhr, settings, thrownError) { + if (jqxhr.status !== undefined && jqxhr.status === 403) { + const loginRequired = jqxhr.getResponseHeader('login-required'); + if (loginRequired !== null) { + alert.question(translation, function (result) { + if (result === true) { + window.location.replace(loginUrl); + } + }); + } + } + }); + } + /** * auto hide success messages, as they are just meant as user feedback and not as a permanent information * diff --git a/config/packages/nelmio_api_doc.yaml b/config/packages/nelmio_api_doc.yaml index ceebe973..62ad9d23 100644 --- a/config/packages/nelmio_api_doc.yaml +++ b/config/packages/nelmio_api_doc.yaml @@ -37,7 +37,7 @@ nelmio_api_doc: info: title: Kimai 2 - API Docs description: | - REST API for the Kimai 2 time-tracking software. Read more about its usage in the [API documentation](https://www.kimai.org/documentation/rest-api.html) and then download a [Swagger file](doc.json) for import e.g. in Postman. + JSON API for the Kimai 2 time-tracking software. Read more about its usage in the [API documentation](https://www.kimai.org/documentation/rest-api.html) and then download a [Swagger file](doc.json) for import e.g. in Postman. Be aware: it is not yet considered stable and BC breaks might happen, but we try to avoid them. version: 0.3 securityDefinitions: diff --git a/public/build/app.608dd464.js b/public/build/app.21c06505.js similarity index 64% rename from public/build/app.608dd464.js rename to public/build/app.21c06505.js index a96f26a5..ee902562 100644 --- a/public/build/app.608dd464.js +++ b/public/build/app.21c06505.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([["app"],{"+2oP":function(t,e,n){"use strict";var i=n("I+eb"),o=n("hh1v"),r=n("6LWA"),s=n("I8vh"),a=n("UMSQ"),l=n("/GqU"),c=n("hBjN"),u=n("Hd5f"),d=n("tiKp")("species"),h=[].slice,p=Math.max;i({target:"Array",proto:!0,forced:!u("slice")},{slice:function(t,e){var n,i,u,f=l(this),m=a(f.length),g=s(t,m),v=s(void 0===e?m:e,m);if(r(f)&&("function"!=typeof(n=f.constructor)||n!==Array&&!r(n.prototype)?o(n)&&null===(n=n[d])&&(n=void 0):n=void 0,n===Array||void 0===n))return h.call(f,g,v);for(i=new(void 0===n?Array:n)(p(v-g,0)),u=0;g")}),u=!r(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2!==n.length||"a"!==n[0]||"b"!==n[1]});t.exports=function(t,e,n,d){var h=s(t),p=!r(function(){var e={};return e[h]=function(){return 7},7!=""[t](e)}),f=p&&!r(function(){var e=!1,n=/a/;return n.exec=function(){return e=!0,null},"split"===t&&(n.constructor={},n.constructor[l]=function(){return n}),n[h](""),!e});if(!p||!f||"replace"===t&&!c||"split"===t&&!u){var m=/./[h],g=n(h,""[t],function(t,e,n,i,o){return e.exec===a?p&&!o?{done:!0,value:m.call(e,n,i)}:{done:!0,value:t.call(n,e,i)}:{done:!1}}),v=g[0],y=g[1];o(String.prototype,t,v),o(RegExp.prototype,h,2==e?function(t,e){return y.call(t,this,e)}:function(t){return y.call(t,this)}),d&&i(RegExp.prototype[h],"sham",!0)}}},"1E5z":function(t,e,n){var i=n("m/L8").f,o=n("UTVS"),r=n("tiKp")("toStringTag");t.exports=function(t,e,n){t&&!o(t=n?t:t.prototype,r)&&i(t,r,{configurable:!0,value:e})}},"1Wo5":function(t,e,n){(function(t){var e=n("EVdn");t.$=t.jQuery=e,n("VSY+"),n("Onkx"),n("DPhY");var i=n("wd/R");t.moment=i,n("jnO4"),n("tGlX"),n("iYuL"),n("nyYc"),n("WxRl"),n("bpih"),n("B55N"),n("Ivi+"),n("0tRk"),n("lXzo"),n("e+ae"),n("X709"),n("eHjp"),n("+jAj"),n("Qiut"),n("vh7O"),n("WySY"),t.$.AdminLTE={},t.$.AdminLTE.options={},n("qG+3"),n("NlKh"),n("zcCC"),n("9/yf")}).call(this,n("yLpj"))},"2B1R":function(t,e,n){"use strict";var i=n("I+eb"),o=n("tycR").map;i({target:"Array",proto:!0,forced:!n("Hd5f")("map")},{map:function(t){return o(this,t,arguments.length>1?arguments[1]:void 0)}})},"2oRo":function(t,e,n){(function(e){var n="object",i=function(t){return t&&t.Math==Math&&t};t.exports=i(typeof globalThis==n&&globalThis)||i(typeof window==n&&window)||i(typeof self==n&&self)||i(typeof e==n&&e)||Function("return this")()}).call(this,n("yLpj"))},"33Wh":function(t,e,n){var i=n("yoRg"),o=n("eDl+");t.exports=Object.keys||function(t){return i(t,o)}},"3UD+":function(t,e){t.exports=function(t){if(!t.webpackPolyfill){var e=Object.create(t);e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),Object.defineProperty(e,"exports",{enumerable:!0}),e.webpackPolyfill=1}return e}},"3bBZ":function(t,e,n){var i=n("2oRo"),o=n("/byt"),r=n("4mDm"),s=n("X2U+"),a=n("tiKp"),l=a("iterator"),c=a("toStringTag"),u=r.values;for(var d in o){var h=i[d],p=h&&h.prototype;if(p){if(p[l]!==u)try{s(p,l,u)}catch(t){p[l]=u}if(p[c]||s(p,c,d),o[d])for(var f in r)if(p[f]!==r[f])try{s(p,f,r[f])}catch(t){p[f]=r[f]}}}},"4Brf":function(t,e,n){"use strict";var i=n("I+eb"),o=n("g6v/"),r=n("2oRo"),s=n("UTVS"),a=n("hh1v"),l=n("m/L8").f,c=n("6JNq"),u=r.Symbol;if(o&&"function"==typeof u&&(!("description"in u.prototype)||void 0!==u().description)){var d={},h=function(){var t=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),e=this instanceof h?new u(t):void 0===t?u():u(t);return""===t&&(d[e]=!0),e};c(h,u);var p=h.prototype=u.prototype;p.constructor=h;var f=p.toString,m="Symbol(test)"==String(u("test")),g=/^Symbol\((.*)\)[^)]+$/;l(p,"description",{configurable:!0,get:function(){var t=a(this)?this.valueOf():this,e=f.call(t);if(s(d,t))return"";var n=m?e.slice(7,-1):e.replace(g,"$1");return""===n?void 0:n}}),i({global:!0,forced:!0},{Symbol:h})}},"4WOD":function(t,e,n){var i=n("UTVS"),o=n("ewvW"),r=n("93I0"),s=n("4Xet"),a=r("IE_PROTO"),l=Object.prototype;t.exports=s?Object.getPrototypeOf:function(t){return t=o(t),i(t,a)?t[a]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?l:null}},"4Xet":function(t,e,n){var i=n("0Dky");t.exports=!i(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})},"4l63":function(t,e,n){var i=n("I+eb"),o=n("5YOQ");i({global:!0,forced:parseInt!=o},{parseInt:o})},"4mDm":function(t,e,n){"use strict";var i=n("/GqU"),o=n("RNIs"),r=n("P4y1"),s=n("afO8"),a=n("fdAy"),l=s.set,c=s.getterFor("Array Iterator");t.exports=a(Array,"Array",function(t,e){l(this,{type:"Array Iterator",target:i(t),index:0,kind:e})},function(){var t=c(this),e=t.target,n=t.kind,i=t.index++;return!e||i>=e.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:i,done:!1}:"values"==n?{value:e[i],done:!1}:{value:[i,e[i]],done:!1}},"values"),r.Arguments=r.Array,o("keys"),o("values"),o("entries")},"5YOQ":function(t,e,n){var i=n("2oRo"),o=n("WKiH").trim,r=n("WJkJ"),s=i.parseInt,a=/^[+-]?0[Xx]/,l=8!==s(r+"08")||22!==s(r+"0x16");t.exports=l?function(t,e){var n=o(String(t));return s(n,e>>>0||(a.test(n)?16:10))}:s},"6JNq":function(t,e,n){var i=n("UTVS"),o=n("Vu81"),r=n("Bs8V"),s=n("m/L8");t.exports=function(t,e){for(var n=o(e),a=s.f,l=r.f,c=0;c",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var e,n,i,o=this.element[0].nodeName.toLowerCase(),r="textarea"===o,s="input"===o;this.isMultiLine=r||!s&&this._isContentEditable(this.element),this.valueMethod=this.element[r||s?"val":"text"],this.isNewMenu=!0,this._addClass("ui-autocomplete-input"),this.element.attr("autocomplete","off"),this._on(this.element,{keydown:function(o){if(this.element.prop("readOnly"))return e=!0,i=!0,void(n=!0);e=!1,i=!1,n=!1;var r=t.ui.keyCode;switch(o.keyCode){case r.PAGE_UP:e=!0,this._move("previousPage",o);break;case r.PAGE_DOWN:e=!0,this._move("nextPage",o);break;case r.UP:e=!0,this._keyEvent("previous",o);break;case r.DOWN:e=!0,this._keyEvent("next",o);break;case r.ENTER:this.menu.active&&(e=!0,o.preventDefault(),this.menu.select(o));break;case r.TAB:this.menu.active&&this.menu.select(o);break;case r.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(o),o.preventDefault());break;default:n=!0,this._searchTimeout(o)}},keypress:function(i){if(e)return e=!1,void(this.isMultiLine&&!this.menu.element.is(":visible")||i.preventDefault());if(!n){var o=t.ui.keyCode;switch(i.keyCode){case o.PAGE_UP:this._move("previousPage",i);break;case o.PAGE_DOWN:this._move("nextPage",i);break;case o.UP:this._keyEvent("previous",i);break;case o.DOWN:this._keyEvent("next",i)}}},input:function(t){if(i)return i=!1,void t.preventDefault();this._searchTimeout(t)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(t){this.cancelBlur?delete this.cancelBlur:(clearTimeout(this.searching),this.close(t),this._change(t))}}),this._initSource(),this.menu=t("