1(function( $ ) { 2 $.fn.gcauth = function(options) { 3 4 var defaults = {}; 5 var settings = $.extend( {}, defaults, options ); 6 7 return this.each(function() { 8 9 var authObj = { 10 11 options : {}, 12 13 widget : null, 14 15 widgetPrivStat : null, 16 17 widgetChangePwd : null, 18 19 redirectURL : '', 20 21 bootstrap : false, 22 23 init : function( options ) 24 { 25 this.options = options; 26 this.redirectURL = this.options.redirect_self; 27 this.bootstrap = typeof this.options.bootstrap !== 'undefined' ? this.options.bootstrap : false; 28 this.showLoginForm(); 29 }, 30 31 disable : function(widget) 32 { 33 widget.form.find("input").prop('disabled', true); 34 widget.controls.find("button, input[type='button'], input[type='submit']").prop('disabled', true); 35 }, 36 37 enable : function(widget) 38 { 39 widget.form.find("input").prop('disabled', false); 40 widget.controls.find("button, input[type='button'], input[type='submit']").prop('disabled', false); 41 }, 42 43 beforSend : function (widget) { 44 widget.css('opacity', 0.4); 45 this.disable(widget); 46 }, 47 48 afterSend: function(widget) { 49 widget.css('opacity', 1.0); 50 this.enable(widget); 51 }, 52 53 displayError : function(message, widget) 54 { 55 // displayError() kann auch mit anderen Widgets aufgerufen werden, 56 // dann ist this.widget nicht sichtbar, daher widget-Param hinzugefügt 57 var id = widget.content.prop('id') + '-message'; 58 $('#' + id).remove(); 59 var $message = $('<div class="message error" role="alert" id="'+id+'">' + message + '</div>'); 60 if (this.bootstrap) { 61 $message = $('<div class="alert alert-danger alert-dismissible fade show" role="alert" id="'+id+'">' + message + '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>'); 62 } 63 widget.content.prepend($message); 64 65 if (!this.bootstrap) { 66 window.setTimeout(function () { 67 $message.fadeOut(400, function () { 68 $message.remove(); 69 }); 70 }, 5000); 71 } 72 }, 73 74 redirect : function() 75 { 76 var location = this.redirectURL; 77 this.widget.widget.fadeOut(100, function() { 78 if (document.location.href === location) 79 { 80 // lädt die aktuelle Seite neu und umgeht den Browser-Cache 81 document.location.reload(true); 82 } 83 else 84 { 85 // ggf. weitere Probleme mit Browser-Cache (siehe http://git.brain-scc.lan/geocms/geocms/issues/649) 86 document.location.href = location; 87 } 88 }); 89 }, 90 91 showLoginForm : function() 92 { 93 var options = this.options; 94 95 var height = 311; 96 if( options.privacy_statement > 0 ) { 97 height += 150; 98 } 99 100 var btnLogin = { 101 'value': options.btnTitle, 102 'name' : options.action, 103 'type' : 'submit', 104 'bootstrap' : this.bootstrap, 105 'class' : 'btn btn-outline-success w-25' 106 }; 107 108 var btnCancel = { 109 'value' : 'Abbrechen', 110 'name' : 'cancel', 111 'class' : 'btn btn-outline-dark w-25', 112 'bootstrap' : this.bootstrap, 113 'click' : function (event) { 114 $(options.selector).gcfewidget('close'); 115 event.preventDefault(); 116 } 117 }; 118 119 var buttons = new Array(); 120 121 if (options.noclose && options.noclose != 0) { 122 buttons.push(btnLogin); 123 } 124 else { 125 buttons.push(btnLogin); 126 buttons.push(btnCancel); 127 } 128 129 if (options.noButtons && options.noButtons != 0) 130 { 131 buttons = new Array(); 132 } 133 134 var $this = this; 135 136 this.widget = $(options.selector).gcfewidget({ 137 'title' : options.title, 138 'url' : options.url, 139 'width' : 640, 140 'height': height, 141 'wrapClass' : 'gc_auth_widget', 142 'autoopen' : (options.autoopen && options.autoopen == 1), 143 'noclose' : (options.noclose && options.noclose == 1), 144 'buttons' : buttons, 145 'onFormSubmit' : function(event) { 146 $this.onSubmit(); 147 event.preventDefault(); 148 }, 149 'onContentLoaded' : function() { 150 if(this.form) 151 { 152 this.form.find("input[name='username']").focus(); 153 this.form.find("input[type='checkbox'][class='slide-box']").gciosswitch({ 154 'title_true' : 'Ja', 155 'title_false' : 'Nein' 156 }); 157 } 158 } 159 }); 160 }, 161 162 onSubmit : function() 163 { 164 if( !this.widget.form ) { 165 return; 166 } 167 168 if( $('#gcauth-goadmin').is(':checked') ) { 169 this.redirectURL = this.options.redirect_admin; 170 } 171 172 var url = this.widget.form.prop('action'); 173 var postData = {}; 174 postData["username"] = $('#gcauth-username').val(); 175 postData["password"] = $('#gcauth-password').val(); 176 177 var $this = this; 178 $.ajax({ 179 cache:false, 180 type:'POST', 181 data:postData, 182 url:url, 183 beforeSend: function(){ $this.beforSend($this.widget); } 184 }) 185 .fail(function( jqXHR, textStatus, errorThrown ) 186 { 187 $this.widget.gcfewidget('shake'); 188 $this.displayError( jqXHR.responseText, $this.widget ); 189 190 if( jqXHR && jqXHR.status == 401 ) { 191 var x_code = jqXHR.getResponseHeader('X-Error-Code') ? +jqXHR.getResponseHeader('X-Error-Code') : 0; 192 switch(x_code) 193 { 194 case 10: 195 $this.afterSend($this.widget); 196 $this.showPasswordChangeInitial(); 197 break; 198 default: 199 $this.afterSend($this.widget); 200 $this.showPasswordExpired(); 201 } 202 203 } 204 }) 205 .done(function(data, textStatus, jqXHR) { 206 if(data && data.result == 1 ) { 207 if( $this.options.privacy_statement == 1 && data.show_privacy_statement == 1 ) {
208 $this.showPrivacyStatement(); 209 } 210 else { 211 if (data.redirect_self) 212 { 213 $this.redirectURL = data.redirect_self; 214 } 215 $this.redirect(); 216 } 217 } 218 else { 219 $this.displayError('Unbekannter Authentifizierungs Fehler', $this.widget); 220 } 221 }) 222 .always(function() { 223 $this.afterSend($this.widget); 224 }); 225 }, 226 227 showPasswordExpired : function() 228 { 229 $(this.widget).gcfewidget('destroy'); 230 231 var wrapId = this.options.selector.substring(2) + '-pwdexp'; 232 var wrapSel = '#' + wrapId; 233 234 if($(wrapSel).length == 0) { 235 $('body').append($('<div id="'+wrapId+'" />')); 236 } 237 238 var $this = this; 239 var height = 500; 240 var buttons = new Array(); 241 242 buttons.push({ 243 'value': 'Speichern', 244 'name' : 'ok', 245 'type' : 'submit', 246 'bootstrap' : this.bootstrap, 247 'class' : 'btn btn-outline-success w-25' 248 }); 249 250 buttons.push({ 251 'value' : 'Abbrechen', 252 'name' : 'cancel', 253 'bootstrap' : this.bootstrap, 254 'class' : 'btn btn-outline-dark w-25', 255 'click' : function (event) { 256 event.preventDefault(); 257 $(wrapSel).gcfewidget('destroy'); 258 $(wrapSel).remove(); 259 } 260 }); 261 262 var idWidget = 'gcfewidget-password-expired'; 263 this.widgetChangePwd = $(wrapSel).gcfewidget({ 264 'title' : this.options.title_expired ? this.options.title_expired : 'Ihr Passwort ist abgelaufen', 265 'idWidget' : idWidget, 266 'url' : $this.options.url_password_expired, 267 'width' : 640, 268 'height': height, 269 'wrapClass' : 'gc_auth_widget', 270 'autoopen' : 1, 271 'noclose' : 0, 272 'buttons' : buttons, 273 'onFormSubmit' : function(event) { 274 event.preventDefault(); 275 $this.onSubmitPasswordExpired(); 276 } 277 }); 278 }, 279 280 281 showPasswordChangeInitial : function() 282 { 283 $(this.widget).gcfewidget('destroy'); 284 285 var wrapId = this.options.selector.substring(2) + '-pwdexp'; 286 var wrapSel = '#' + wrapId; 287 288 if($(wrapSel).length == 0) { 289 $('body').append($('<div id="'+wrapId+'" />')); 290 } 291 292 var $this = this; 293 var height = 500; 294 var buttons = new Array(); 295 296 buttons.push({ 297 'value': 'Speichern', 298 'name' : 'ok', 299 'type' : 'submit', 300 'bootstrap' : this.bootstrap, 301 'class' : 'btn btn-outline-success w-25' 302 }); 303 304 buttons.push({ 305 'value' : 'Abbrechen', 306 'name' : 'cancel', 307 'bootstrap' : this.bootstrap, 308 'class' : 'btn btn-outline-dark w-25', 309 'click' : function (event) { 310 event.preventDefault(); 311 $(wrapSel).gcfewidget('destroy'); 312 $(wrapSel).remove(); 313 } 314 }); 315 316 var idWidget = 'gcfewidget-password-change-initial'; 317 this.widgetChangePwd = $(wrapSel).gcfewidget({ 318 'title' : this.options.title_initial ? this.options.title_initial : 'Initialpasswort bitte ändern', 319 'idWidget' : idWidget, 320 'url' : $this.options.url_password_change_initial, 321 'width' : 640, 322 'height': height, 323 'wrapClass' : 'gc_auth_widget', 324 'autoopen' : 1, 325 'noclose' : 0, 326 'buttons' : buttons, 327 'onFormSubmit' : function(event) { 328 event.preventDefault(); 329 $this.onSubmitPasswordChangeInitial(); 330 } 331 }); 332 }, 333 334 onSubmitPasswordExpired : function() 335 { 336 var form = this.widgetChangePwd.form; 337 var url = form.prop('action'); 338 var postData = {}; 339 340 //postData = this.widgetChangePwd.form.serialize(); 341 postData["password_current"] = $('#password_current').val(); 342 postData["password"] = $('#password').val(); 343 postData["password_confirm"] = $('#password_confirm').val(); 344 345 var $this = this; 346 var $widget = this.widgetChangePwd; 347 $.ajax({ 348 cache:false, 349 type:'POST', 350 data:postData, 351 url: url 352 }) 353 .fail(function(jqXHR, textStatus, errorThrown) { 354 $widget.gcfewidget('shake'); 355 $this.displayError( jqXHR.responseText, $widget ); 356 }) 357 .done(function(data, textStatus, jqXHR) { 358 if(data && data.result == 1 ) 359 { 360 $($widget).gcfewidget('destroy'); 361 362 if( $this.options.privacy_statement == 1 && data.show_privacy_statement == 1 ) {
363 $this.showPrivacyStatement(); 364 } 365 else { 366 $this.redirect(); 367 } 368 } 369 else { 370 $this.displayError( "Unbekannter Fehler", $widget ); 371 } 372 }); 373 }, 374 375 onSubmitPasswordChangeInitial : function() 376 { 377 var form = this.widgetChangePwd.form; 378 var url = form.prop('action'); 379 var postData = {}; 380 381 postData["password_current"] = $('#password_current').val(); 382 postData["password"] = $('#password').val(); 383 postData["password_confirm"] = $('#password_confirm').val(); 384 385 var $this = this; 386 var $widget = this.widgetChangePwd; 387 $.ajax({ 388 cache:false, 389 type:'POST', 390 data:postData, 391 url: url 392 }) 393 .fail(function(jqXHR, textStatus, errorThrown) { 394 $widget.gcfewidget('shake'); 395 $this.displayError( jqXHR.responseText, $widget ); 396 }) 397 .done(function(data, textStatus, jqXHR) { 398 if(data && data.result == 1 ) 399 { 400 $($widget).gcfewidget('destroy'); 401 402 if( $this.options.privacy_statement == 1 && data.show_privacy_statement == 1 ) { 403 $this.showPrivacyStatement(); 404 } 405 else { 406 $this.redirect(); 407 } 408 } 409 else { 410 $this.displayError( "Unbekannter Fehler", $widget ); 411 } 412 }); 413 }, 414 415 showPrivacyStatement : function() 416 { 417 $(this.widget).gcfewidget('destroy'); 418 419 var $this = this; 420 var height = 500; 421 var buttons = new Array(); 422 423 var wrapId = this.options.selector.substring(2) + '-privconf'; 424 var wrapSel = '#' + wrapId; 425 426 if($(wrapSel).length == 0) { 427 $('body').append($('<div id="'+wrapId+'" />')); 428 } 429 430 buttons.push({ 431 'value': 'Weiter', 432 'name' : 'ok', 433 'type' : 'submit', 434 'class' : 'highlighted' 435 }); 436 437 buttons.push({ 438 'value' : 'Abbrechen', 439 'name' : 'cancel', 440 'click' : function (event) { 441 $(wrapSel).gcfewidget('close'); 442 $this.onCancelPrivacyStatement(); 443 event.preventDefault(); 444 } 445 }); 446 447 this.widgetPrivStat = $(wrapSel).gcfewidget({ 448 'title' : 'Datenschutzerklärung', 449 'idWidget' : 'gcfewidget-privacy-statement', 450 'url' : $this.options.url_privacy_statement, 451 'width' : 640, 452 'height': height, 453 'wrapClass' : 'gc_auth_widget', 454 'autoopen' : 1, 455 'noclose' : 1, 456 'buttons' : buttons, 457 'onFormSubmit' : function(event) { 458 event.preventDefault(); 459 $this.onSubmitPrivacyStatement(); 460 }, 461 'onContentLoaded' : function() { 462 if(this.form) { 463 $this.processPrivacyStatement(); 464 } 465 } 466 }); 467 }, 468 469 processPrivacyStatement : function() 470 { 471 this.disable(this.widgetPrivStat); 472 var $submit = this.widgetPrivStat.controls.find("input[type='submit']"); 473 var $accept = this.widgetPrivStat.form.find("input.slide-box[type='checkbox']"); 474 475 $accept.qtip({ 476 content: { 477 text: 'Um fortzufahren müssen Sie noch Ihre Zustimmung abgeben.' 478 }, 479 style: { 480 classes: 'qtip-light' 481 }, 482 position: { 483 my: 'top left', 484 at: 'bottom center', 485 target: false 486 }, 487 show: { 488 ready: false 489 }, 490 hide: { 491 event: 'unfocus' 492 } 493 }); 494 495 $accept.gciosswitch({ 496 'title_true' : 'Ja', 497 'title_false' : 'Nein' 498 }) 499 .on('click', function(event) { 500 if( $(this).is(':checked') ) { 501 $submit./*prop('disabled', false).*/addClass('highlight'); 502 } 503 else { 504 $submit./*prop('disabled', true).*/removeClass('highlight'); 505 } 506 }); 507 // initial Submit deaktivieren 508 $submit./*prop('disabled', true).*/removeClass('highlight'); 509 510 var $this = this; 511 if($('#gcauth-statement').outerHeight() > 200) { 512 $('#gcauth-statement').scroll(function() { 513 var srollpos = ($(this)[0].scrollHeight - $(this).scrollTop()); 514 if(Math.abs(srollpos - $(this).outerHeight()) < 3) { 515 $('#gcauth-privacy-accept').addClass('highlight'); 516 $this.enable($this.widgetPrivStat); 517 } 518 else { 519 $('#gcauth-privacy-accept').removeClass('highlight'); 520 $this.disable($this.widgetPrivStat); 521 } 522 }); 523 } 524 else { 525 $('#gcauth-privacy-accept').addClass('highlight'); 526 $this.enable($this.widgetPrivStat); 527 } 528 }, 529 530 onCancelPrivacyStatement : function() 531 { 532 var $this = this; 533 // pauschal AJAX gegen Seite mit dem auth-Modul fahren, dadurch wird in der Verarbeitung des auth-Moduls der Benutzer wieder abgemeldet 534 $.ajax({ 535 cache:false, 536 type:'GET', 537 url: $this.redirectURL 538 }); 539 }, 540 541 onSubmitPrivacyStatement : function() 542 { 543 var hasAgreed = this.widgetPrivStat.form.find("input.slide-box[type='checkbox']").is(':checked'); 544 if(hasAgreed) 545 { 546 var url = this.widgetPrivStat.form.prop('action'); 547 var postData = this.widgetPrivStat.form.serialize(); 548 549 var $this = this; 550 $.ajax({ 551 cache:false, 552 type:'POST', 553 data:postData, 554 url: url 555 }) 556 .fail(function(jqXHR, textStatus, errorThrown ) { 557 $this.widgetPrivStat.gcfewidget('shake'); 558 $this.displayError( jqXHR.responseText, $this.widgetPrivStat ); 559 }) 560 .done(function(data, textStatus, jqXHR) { 561 $this.redirect(); 562 }); 563 } 564 else 565 { 566 var wrapId = this.options.selector.substring(2) + '-privconf'; 567 var wrapSel = '#' + wrapId; 568 jQuery(wrapSel).gcfewidget('shake'); 569 this.widgetPrivStat.form.find("input.slide-box[type='checkbox']").qtip().show(); 570 } 571 } 572 }; 573 574 authObj.init(settings); 575 return this; 576 }); 577 }; 578}( jQuery ));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.