improve add account flow

This commit is contained in:
grimhilt
2023-07-16 16:24:30 +02:00
parent f40b6758de
commit ae73326820
8 changed files with 29 additions and 24 deletions

View File

@@ -1,12 +1,12 @@
import { execQueryAsync, execQueryAsyncWithId } from "./db";
import { queryCcId, queryToId, queryFromId } from "./utils/addressQueries";
export async function registerAccount(userId, pwd, xoauth, xoauth2, host, port, tls) {
export async function registerAccount(userId, pwd, xoauth, xoauth2, imapHost, smtpHost, imapPort, smtpPort, tls) {
const query = `
INSERT INTO app_account
(user_id, account_pwd, xoauth, xoauth2, host, port, tls) VALUES (?, ?, ?, ?, ?, ?, ?)
(user_id, account_pwd, xoauth, xoauth2, imap_host, smtp_host, imap_port, smtp_port, tls) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
`;
const values = [userId, pwd, xoauth, xoauth2, host, port, tls];
const values = [userId, pwd, xoauth, xoauth2, imapHost, smtpHost, imapPort, smtpPort, tls];
return await execQueryAsyncWithId(query, values);
}

View File

@@ -18,8 +18,10 @@ CREATE TABLE app_account (
account_pwd BINARY(22),
xoauth VARCHAR(116),
xoauth2 VARCHAR(116),
host VARCHAR(255) NOT NULL DEFAULT 'localhost',
port INT(5) NOT NULL DEFAULT 143,
imap_host VARCHAR(255) NOT NULL DEFAULT 'localhost',
imap_port INT(5) NOT NULL DEFAULT 993,
smtp_host VARCHAR(255) NOT NULL DEFAULT 'localhost',
smtp_port INT(5) NOT NULL DEFAULT 465,
tls BOOLEAN NOT NULL DEFAULT true,
PRIMARY KEY (account_id),
FOREIGN KEY (user_id) REFERENCES address(address_id) ON DELETE CASCADE

View File

@@ -6,9 +6,11 @@ export async function getAllAccounts() {
app_account.account_id AS id,
address.email AS user,
app_account.account_pwd AS password,
app_account.host AS host,
app_account.port AS port,
app_account.tls AS tls
app_account.imap_host,
app_account.imap_port,
app_account.smtp_host,
app_account.smtp_port,
app_account.tls
FROM app_account INNER JOIN address
WHERE address.address_id = app_account.user_id
`;