2 <span id="login_button_html_div" style="white-space:nowrap;width:200;float:right"><button class="btn btn-primary disabled" type="button" style="margin: 7px 7px 0px 0px">Login</button></span>
7 // Add URL paths to this array that should not have the login dialog shown
8 // when the config `require_login` is set
9 const PATHS_TO_NOT_REQUIRE_LOGIN = ["/user/reset_password_form"];
11 function update_login_button() {
14 url: '/ajax/user/login_button_html',
15 error: function(r) { alert('An error occurred'); },
16 success: function(r) {
17 if (r.error) { alert(r.error); }
19 jQuery('#login_button_html_div').html(r.html);
21 if (<% $c->config->{require_login} %> == 1 && !r.logged_in) {
22 if ( !PATHS_TO_NOT_REQUIRE_LOGIN.includes(window.location.pathname) ) {
23 jQuery('#site_login_dialog').modal({backdrop: 'static', keyboard: false});
32 var answer = confirm("Are you sure you want to log out?");
34 if (answer === true) {
36 url: '/ajax/user/logout',
37 error: function(r) { alert('An error occurred'); },
38 success: function(r) {
39 if (r.error) { alert(r.error); }
48 jQuery(document).ready(function () {
50 update_login_button();
52 jQuery(document).on('click', 'button[name="site_login_button"]', function(event)
54 jQuery('#site_login_dialog').modal("show");