summaryrefslogtreecommitdiff
path: root/src/web/_views/auth/main.php
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-12-23 11:13:27 -0500
committerFreya Murphy <freya@freyacat.org>2024-12-23 11:13:27 -0500
commit5a2ba9c2e7605bb788bc406184547d22c6436867 (patch)
treecbd988d534e8a8593a31d70571222443f80da0b3 /src/web/_views/auth/main.php
parentfix about modal (diff)
downloadxssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.gz
xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.bz2
xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.zip
v2.1.0, refactor w/ crimson
Diffstat (limited to 'src/web/_views/auth/main.php')
-rw-r--r--src/web/_views/auth/main.php87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/web/_views/auth/main.php b/src/web/_views/auth/main.php
new file mode 100644
index 0000000..9604770
--- /dev/null
+++ b/src/web/_views/auth/main.php
@@ -0,0 +1,87 @@
+<?php /* Copyright (c) 2024 Freya Murphy */ ?>
+<?php /* vi: syntax=php */ ?>
+<main id="main">
+ <div class="branding col">
+ <h1>xssbook</h1>
+ <span><?=ucfirst(lang('login_branding'))?></span>
+ </div>
+ <div class="form card col">
+ <form id="action-login" class="col" action="">
+ <div class="form-input mb">
+ <input
+ type="text"
+ name="username"
+ id="login-username"
+ placeholder=" "
+ autofocus="true"
+ >
+ <label for="username">
+ <?=ucfirst(lang('ph_username'))?>
+ </label>
+ </div>
+ <div class="form-input mb">
+ <input
+ type="password"
+ name="password"
+ id="login-password"
+ placeholder=" "
+ >
+ <label for="password">
+ <?=ucfirst(lang('ph_password'))?>
+ </label>
+ </div>
+ <?=ilang('action_login',
+ class: 'btn btn-primary btn-alt grow',
+ type: 'button',
+ attrs: array('type' => 'submit')
+ )?>
+ <?/*=ilang('action_forgot_passwd',
+ class: 'btn btn-blend btn-primary grow mt'
+ )*/?>
+ </form>
+ <hr>
+ <?=ilang('action_create_account',
+ id: 'action-register',
+ class: 'btn btn-success btn-alt grow',
+ type: 'button',
+ attrs: array('type' => 'submit')
+ )?>
+ </div>
+ <script>
+
+ const onLogin = function(data) {
+ let jwt = data.token;
+
+ $.ajax({
+ url: '/auth/update',
+ method: 'POST',
+ data: JSON.stringify({
+ key: 'jwt',
+ value: jwt
+ }),
+ success: function (_) {
+ window.location = '/home';
+ }
+ })
+ };
+
+ $('#action-login').on('submit', function(e) {
+ e.preventDefault();
+ let username = $('#login-username').val();
+ let password = $('#login-password').val();
+
+ $.ajax({
+ url: '/api/rpc/login',
+ method: 'POST',
+ data: JSON.stringify({ username, password }),
+ success: onLogin
+ });
+ });
+
+ $('#action-register').on('click', function() {
+ $.get( "/_modal/register", function (data) {
+ $(document.body).append(data);
+ });
+ })
+ </script>
+</main>