@@ -2,11 +2,11 @@ const tb = parent.window.tb;
2
2
const currentAccountsEl = document . querySelector ( ".current-accounts" ) ;
3
3
4
4
const getAccounts = async ( ) => {
5
- const entries = await Filer . fs . promises . readdir ( "/home/" ) ;
5
+ const entries = await tb . fs . promises . readdir ( "/home/" ) ;
6
6
const accounts = await Promise . all (
7
7
entries . map ( async entry => {
8
8
try {
9
- const account = JSON . parse ( await Filer . fs . promises . readFile ( `/home/${ entry } /user.json` , "utf8" ) ) ;
9
+ const account = JSON . parse ( await tb . fs . promises . readFile ( `/home/${ entry } /user.json` , "utf8" ) ) ;
10
10
return {
11
11
name : entry ,
12
12
id : account [ "id" ] ,
@@ -24,10 +24,10 @@ const getAccounts = async () => {
24
24
} ;
25
25
26
26
const deleteAccount = async id => {
27
- const sudoUsers = JSON . parse ( await Filer . fs . promises . readFile ( "/system/etc/terbium/sudousers.json" , "utf8" ) ) ;
27
+ const sudoUsers = JSON . parse ( await tb . fs . promises . readFile ( "/system/etc/terbium/sudousers.json" , "utf8" ) ) ;
28
28
let sudoWithPassword = null ;
29
29
for ( const sudoUser of sudoUsers ) {
30
- const sudoUserData = JSON . parse ( await Filer . fs . promises . readFile ( `/home/${ sudoUser } /user.json` , "utf8" ) ) ;
30
+ const sudoUserData = JSON . parse ( await tb . fs . promises . readFile ( `/home/${ sudoUser } /user.json` , "utf8" ) ) ;
31
31
if ( sudoUserData . password !== false ) {
32
32
sudoWithPassword = sudoUser ;
33
33
break ;
@@ -48,7 +48,7 @@ const deleteAccount = async id => {
48
48
defaultUsername : sudoUsers [ 0 ] ,
49
49
onOk : async ( username , password ) => {
50
50
const pass = await tb . crypto ( password ) ;
51
- if ( pass === JSON . parse ( await Filer . fs . promises . readFile ( `/home/${ sudoUsers [ 0 ] } /user.json` , "utf8" ) ) . password ) {
51
+ if ( pass === JSON . parse ( await tb . fs . promises . readFile ( `/home/${ sudoUsers [ 0 ] } /user.json` , "utf8" ) ) . password ) {
52
52
tb . system . users . remove ( id ) ;
53
53
document . getElementById ( id ) . remove ( ) ;
54
54
} else {
@@ -62,7 +62,7 @@ const deleteAccount = async id => {
62
62
} ,
63
63
} ) ;
64
64
} else {
65
- const pw = JSON . parse ( await Filer . fs . promises . readFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , "utf8" ) ) . password ;
65
+ const pw = JSON . parse ( await tb . fs . promises . readFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , "utf8" ) ) . password ;
66
66
if ( pw === false ) {
67
67
await tb . system . users . remove ( id ) ;
68
68
document . getElementById ( id ) . remove ( ) ;
@@ -88,7 +88,7 @@ const deleteAccount = async id => {
88
88
} ;
89
89
90
90
const changePerm = async ( ) => {
91
- const data = JSON . parse ( await Filer . fs . promises . readFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , "utf8" ) ) ;
91
+ const data = JSON . parse ( await tb . fs . promises . readFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , "utf8" ) ) ;
92
92
if ( data [ "password" ] === false ) {
93
93
await tb . dialog . Select ( {
94
94
title : "Enter the permission level you wish to set (Ex: Admin, User, Group, Public)" ,
@@ -114,7 +114,7 @@ const changePerm = async () => {
114
114
if ( perm === data [ "perm" ] ) return ;
115
115
data [ "perm" ] = perm ;
116
116
permEl . innerHTML = perm . charAt ( 0 ) . toUpperCase ( ) + perm . slice ( 1 ) ;
117
- await Filer . fs . promises . writeFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , JSON . stringify ( data ) ) ;
117
+ await tb . fs . promises . writeFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , JSON . stringify ( data ) ) ;
118
118
} ,
119
119
} ) ;
120
120
} else {
@@ -149,7 +149,7 @@ const changePerm = async () => {
149
149
if ( perm === data [ "perm" ] ) return ;
150
150
data [ "perm" ] = perm ;
151
151
permEl . innerHTML = perm . charAt ( 0 ) . toUpperCase ( ) + perm . slice ( 1 ) ;
152
- await Filer . fs . promises . writeFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , JSON . stringify ( data ) ) ;
152
+ await tb . fs . promises . writeFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , JSON . stringify ( data ) ) ;
153
153
} ,
154
154
} ) ;
155
155
} else {
@@ -161,7 +161,7 @@ const changePerm = async () => {
161
161
} ;
162
162
163
163
const changePfp = async id => {
164
- const data = JSON . parse ( await Filer . fs . promises . readFile ( `/home/${ id . id } /user.json` , "utf8" ) ) ;
164
+ const data = JSON . parse ( await tb . fs . promises . readFile ( `/home/${ id . id } /user.json` , "utf8" ) ) ;
165
165
const pfpInp = document . createElement ( "input" ) ;
166
166
pfpInp . type = "file" ;
167
167
pfpInp . accept = "image/*" ;
@@ -176,7 +176,7 @@ const changePfp = async id => {
176
176
img : e . target . result ,
177
177
onOk : async img => {
178
178
data [ "pfp" ] = img ;
179
- await Filer . fs . promises . writeFile ( `/home/${ id . id } /user.json` , JSON . stringify ( data ) ) ;
179
+ await tb . fs . promises . writeFile ( `/home/${ id . id } /user.json` , JSON . stringify ( data ) ) ;
180
180
parent . window . dispatchEvent ( new Event ( "accUpd" ) ) ;
181
181
renderAccounts ( ) ;
182
182
} ,
@@ -329,10 +329,10 @@ const createAccount = async () => {
329
329
} ) ;
330
330
} ;
331
331
332
- const sudoUsers = JSON . parse ( await Filer . fs . promises . readFile ( "/system/etc/terbium/sudousers.json" , "utf8" ) ) ;
332
+ const sudoUsers = JSON . parse ( await tb . fs . promises . readFile ( "/system/etc/terbium/sudousers.json" , "utf8" ) ) ;
333
333
let sudoWithPassword = null ;
334
334
for ( const sudoUser of sudoUsers ) {
335
- const sudoUserData = JSON . parse ( await Filer . fs . promises . readFile ( `/home/${ sudoUser } /user.json` , "utf8" ) ) ;
335
+ const sudoUserData = JSON . parse ( await tb . fs . promises . readFile ( `/home/${ sudoUser } /user.json` , "utf8" ) ) ;
336
336
if ( sudoUserData . password !== false ) {
337
337
sudoWithPassword = sudoUser ;
338
338
break ;
@@ -352,7 +352,7 @@ const createAccount = async () => {
352
352
defaultUsername : sudoWithPassword ,
353
353
onOk : async ( username , password ) => {
354
354
const pass = await tb . crypto ( password ) ;
355
- if ( pass === JSON . parse ( await Filer . fs . promises . readFile ( `/home/${ sudoWithPassword } /user.json` , "utf8" ) ) . password ) {
355
+ if ( pass === JSON . parse ( await tb . fs . promises . readFile ( `/home/${ sudoWithPassword } /user.json` , "utf8" ) ) . password ) {
356
356
askNewAccountDetails ( ) ;
357
357
} else {
358
358
tb . dialog . Alert ( {
@@ -365,7 +365,7 @@ const createAccount = async () => {
365
365
} ,
366
366
} ) ;
367
367
} else {
368
- const user = JSON . parse ( await Filer . fs . promises . readFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , "utf8" ) ) ;
368
+ const user = JSON . parse ( await tb . fs . promises . readFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , "utf8" ) ) ;
369
369
if ( user [ "password" ] === false ) {
370
370
askNewAccountDetails ( ) ;
371
371
} else {
@@ -374,7 +374,7 @@ const createAccount = async () => {
374
374
defaultUsername : sessionStorage . getItem ( "currAcc" ) ,
375
375
onOk : async ( username , password ) => {
376
376
const pass = await tb . crypto ( password ) ;
377
- if ( pass === JSON . parse ( await Filer . fs . promises . readFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , "utf8" ) ) . password ) {
377
+ if ( pass === JSON . parse ( await tb . fs . promises . readFile ( `/home/${ sessionStorage . getItem ( "currAcc" ) } /user.json` , "utf8" ) ) . password ) {
378
378
askNewAccountDetails ( ) ;
379
379
} else {
380
380
tb . dialog . Alert ( {
0 commit comments