mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 08:30:39 +00:00
Add UIWindow2FASetup
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user