Merge pull request #2754 from solgenomics/topic/fix_homepage_add_accessions_dialog
[sgn.git] / mason / site / login_dialog.mas
blob6d3c869eb1e27c52071597ed49a0aa0242cdb2eb
2 <!-- Login Dialog -->
4 <%args>
5 $goto_url => ''
6 </%args>
8 <div class="modal fade" id="site_login_dialog" name="site_login_dialog" tabindex="-1" role="dialog" aria-labelledby="site_login_dialog_title">
9   <div class="modal-dialog modal-sm" role="document">
10     <div class="modal-content">
11       <div class="modal-header" style="text-align:center">
12         <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
13         <h3 class="modal-title" id="site_login_dialog_title">Login</h3>
14       </div>
15       <div class="modal-body">
16         <form id="login_form" name="login_form">
17         <div class="container-fluid">
19 % if ($c->config->{default_login_janedoe}) {
20             <input class="form-control" style="width:240px" id="username" name="username" placeholder="Username" type="text" value="janedoe"/>
21             <br />
22         <input class="form-control" style="width:240px" id="password" name="password" placeholder="Password" type="password" value="secretpw"/>
23 % } else {
24         <input class="form-control" style="width:240px" id="username" name="username" placeholder="Username" type="text" />
25         <br />
26         <input class="form-control" style="width:240px" id="password" name="password" placeholder="Password" type="password" />
27 % }
28             <br />
29             <div style="margin-bottom:40px">
30               <a href="/user/reset_password" style="float:left">Forgot password?</a>
31               <a href="/user/new" style="float:right">New User</a>
32             </div>
33             
34             <input type="hidden" value="<% $goto_url %>" id="goto_url" name="goto_url" />
35             
36             <div>
37               <button class="btn btn-secondary" id="cancel_login" type="reset" style="float:left" >Reset</button>
38               <button class="btn btn-primary" id="submit_password" name="submit_password" type="submit" style="float:right">Login</button>
39             </div>          
40         </div>
41         </form>
42       </div>
43       <div class="modal-footer">
44         <button id="close_site_login_dialog_button" type="button" class="btn btn-default" data-dismiss="modal" style="float:left">Close</button>
45       </div>
46     </div>
47   </div>
48 </div>
50 <script>
51   jQuery(document).ready( function() { 
52     jQuery('#login_form').submit( function(event) { 
53        event.preventDefault();
54        var form_data = jQuery('#login_form').serialize();
55        if (!jQuery('#username').val() || !jQuery('#password').val()) { 
56          alert('Please enter a username and password');
57          return;
58        }
59        jQuery.ajax( { 
60          url: '/ajax/user/login',
61          data: form_data,
62          error: function(r) { alert('An error occurred! Sorry!');  },
63          success: function(r) {
64            if (r.error) { 
65              alert(r.error); 
66              return;
67            }
68            if (r.goto_url) { 
69              location.href=r.goto_url;
70            }
71            else {      
72              location.reload();
73            }
74          }
75        });
76     });
77  });
78 </script>
81 <!-- End login dialog -->