Add UIWindow2FASetup

This commit is contained in:
KernelDeimos
2024-05-02 22:29:17 -04:00
parent 6e0cdb8a6b
commit a672b8a58c
3 changed files with 85 additions and 1 deletions
+6
View File
@@ -1,3 +1,4 @@
import UIWindow2FASetup from "../UIWindow2FASetup.js";
import UIWindowQR from "../UIWindowQR.js";
export default {
@@ -46,6 +47,11 @@ export default {
},
init: ($el_window) => {
$el_window.find('.enable-2fa').on('click', async function (e) {
UIWindow2FASetup();
return;
const resp = await fetch(`${api_origin}/auth/configure-2fa/setup`, {
method: 'POST',
headers: {
+51
View File
@@ -0,0 +1,51 @@
import UIWindow from './UIWindow.js'
import Placeholder from "../util/Placeholder.js"
/**
* @typedef {Object} UIComponentWindowOptions
* @property {Component} A component to render in the window
*/
/**
* Render a UIWindow that contains an instance of Component
* @param {UIComponentWindowOptions} options
*/
export default async function UIComponentWindow (options) {
const placeholder = Placeholder();
await UIWindow({
title: 'Instant Login!',
app: 'instant-login',
single_instance: true,
icon: null,
uid: null,
is_dir: false,
body_content: placeholder.html,
has_head: false,
selectable_body: false,
allow_context_menu: false,
is_resizable: false,
is_droppable: false,
init_center: true,
allow_native_ctxmenu: false,
allow_user_select: false,
backdrop: true,
width: 550,
height: 'auto',
dominant: true,
show_in_taskbar: false,
draggable_body: true,
onAppend: function(this_window){
},
window_class: 'window-qr',
body_css: {
width: 'initial',
height: '100%',
'background-color': 'rgb(245 247 249)',
'backdrop-filter': 'blur(3px)',
padding: '20px',
},
})
options.component.attach(placeholder);
}
+28 -1
View File
@@ -19,5 +19,32 @@
*/
import Flexer from "./Components/Flexer.js";
import QRCodeView from "./Components/QRCode.js";
import UIComponentWindow from "./UIComponentWindow.js";
const UIWindow2FASetup = async function UIWindow2FASetup () {
}
const resp = await fetch(`${api_origin}/auth/configure-2fa/setup`, {
method: 'POST',
headers: {
Authorization: `Bearer ${puter.authToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({}),
});
const data = await resp.json();
const component = new Flexer({
children: [
new QRCodeView({
value: data.url,
})
]
});
UIComponentWindow({
component,
});
}
export default UIWindow2FASetup;