|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <title>aiohttp admin</title> |
| 5 | + <meta charset="utf-8"> |
| 6 | + <meta content="width=device-width, initial-scale=1" name="viewport"> |
| 7 | + <link href="{{ url('admin.static', filename='css/login.css') }}" rel="stylesheet"> |
| 8 | + <link href="{{ url('admin.static', filename='css/ng-admin.min.css') }}" rel="prefetch"> |
| 9 | + <link href="{{ url('admin.static', filename='js/ng-admin.min.js') }}" rel="prefetch"> |
| 10 | + <link href="{{ url('admin.config', filename='config.js') }}" rel="prefetch"> |
| 11 | +</head> |
| 12 | +<body> |
| 13 | + <div class="login-page"> |
| 14 | + <div class="form"> |
| 15 | + <p>aiohttp_admin</p> |
| 16 | + <form class="login-form" onsubmit="return login()"> |
| 17 | + <input id="username" placeholder="username" type="text"> |
| 18 | + <input id="password" placeholder="password" type="password"> |
| 19 | + <button>login</button> |
| 20 | + <p class="message"><a href="http://github.com/aio-libs/aiohttp_admin">http://github.com/aio-libs/aiohttp_admin</a></p> |
| 21 | + </form> |
| 22 | + </div> |
| 23 | + </div> |
| 24 | + <script type="application/x-javascript"> |
| 25 | + window.addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); |
| 26 | + function hideURLbar(){ |
| 27 | + window.scrollTo(0,1); |
| 28 | + } |
| 29 | + function login(e) { |
| 30 | + if (e) { |
| 31 | + e.preventDefault(); |
| 32 | + } |
| 33 | + var request = new XMLHttpRequest(); |
| 34 | + var data = {"username": document.getElementById('username').value, |
| 35 | + "password": document.getElementById('password').value} |
| 36 | + request.open('POST', '/admin/login', true); |
| 37 | + request.setRequestHeader('Content-Type', 'application/json'); |
| 38 | + request.onload = function() { |
| 39 | + if (request.status >= 200 && request.status < 400) { |
| 40 | + var respData = JSON.parse(request.responseText); |
| 41 | + window.localStorage.setItem('aiohttp_admin_token', respData); |
| 42 | + var redirect = request.getResponseHeader("location"); |
| 43 | + window.location = redirect; |
| 44 | + } else { |
| 45 | + alert("go wrong status code"); |
| 46 | + } |
| 47 | + }; |
| 48 | + request.onerror = function() { |
| 49 | + alert("Connection Error"); |
| 50 | + }; |
| 51 | + request.send(JSON.stringify(data)); |
| 52 | + } |
| 53 | + </script> |
| 54 | +</body> |
| 55 | +</html> |
0 commit comments