aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/assets/js/initial_key_gen.js30
-rw-r--r--resources/views/auth/login.blade.php4
-rw-r--r--resources/views/auth/register.blade.php6
3 files changed, 37 insertions, 3 deletions
diff --git a/resources/assets/js/initial_key_gen.js b/resources/assets/js/initial_key_gen.js
new file mode 100644
index 0000000..1b6875f
--- /dev/null
+++ b/resources/assets/js/initial_key_gen.js
@@ -0,0 +1,30 @@
+$('form[keygen]').submit((event) => {
+ event.preventDefault();
+
+ $('button[type="submit"]').attr("disabled", true).html('Loading...');
+
+ var openpgp = window.openpgp;
+
+ var options = {
+ userIds: [{
+ email: $("input#email").val()
+ }],
+ numBits: 4096,
+ passphrase: $("input#password").val()
+ };
+
+ openpgp.generateKey(options).then((key) => {
+ var privateKey = key.privateKeyArmored;
+ var publicKey = key.publicKeyArmored;
+
+ localStorage.setItem("privkey", privateKey);
+
+ var now = new Date();
+ var time = now.getTime();
+ time += 3600 * 1000;
+ now.setTime(time);
+ document.cookie = "publickey=" + encodeURI(publicKey.substr(96).slice(0, -35)) + "; expires=" + now.toUTCString() + ";";
+
+ $('form[keygen]').unbind('submit').submit();
+ });
+}); \ No newline at end of file
diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php
index 9fd12a7..119cfe1 100644
--- a/resources/views/auth/login.blade.php
+++ b/resources/views/auth/login.blade.php
@@ -1,6 +1,8 @@
@extends('layouts.app')
@section('content')
+<script src="{{ asset('js/initial_key_gen.js') }}" defer></script>
+
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
@@ -8,7 +10,7 @@
<div class="card-header">{{ __('Login') }}</div>
<div class="card-body">
- <form method="POST" action="{{ route('login') }}" aria-label="{{ __('Login') }}">
+ <form keygen method="POST" action="{{ route('login') }}" aria-label="{{ __('Login') }}">
@csrf
<div class="form-group row">
diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php
index f9dd662..150046d 100644
--- a/resources/views/auth/register.blade.php
+++ b/resources/views/auth/register.blade.php
@@ -1,6 +1,8 @@
@extends('layouts.app')
@section('content')
+<script src="{{ asset('js/initial_key_gen.js') }}" defer></script>
+
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
@@ -8,7 +10,7 @@
<div class="card-header">{{ __('Register') }}</div>
<div class="card-body">
- <form method="POST" action="{{ route('register') }}" aria-label="{{ __('Register') }}">
+ <form keygen method="POST" action="{{ route('register') }}" aria-label="{{ __('Register') }}">
@csrf
<div class="form-group row">
@@ -63,7 +65,7 @@
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
- <button type="submit" class="btn btn-primary">
+ <button disabled type="submit" class="btn btn-primary">
{{ __('Register') }}
</button>
</div>