Skip to content

Commit

Permalink
Merge pull request #33 from gheinzer/mail-beta
Browse files Browse the repository at this point in the history
Users now have to confirm their e-mail address after registration.
  • Loading branch information
gheinzer committed Oct 12, 2021
2 parents 034f3b3 + 481fbcf commit 371d975
Show file tree
Hide file tree
Showing 8 changed files with 496 additions and 46 deletions.
116 changes: 83 additions & 33 deletions officr_db_structure.sql
@@ -1,14 +1,13 @@
-- phpMyAdmin SQL Dump
-- version 4.9.7deb1
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Erstellungszeit: 28. Sep 2021 um 21:49
-- Server-Version: 8.0.26-0ubuntu0.21.04.3
-- PHP-Version: 7.4.16
-- Host: 127.0.0.1
-- Erstellungszeit: 12. Okt 2021 um 18:18
-- Server-Version: 10.4.19-MariaDB
-- PHP-Version: 8.0.6

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";

Expand All @@ -26,15 +25,53 @@ USE `officr`;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `notifications`
--

CREATE TABLE `notifications` (
`ID` int(11) NOT NULL,
`Title` text NOT NULL,
`Text` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `notifications_seen`
--

CREATE TABLE `notifications_seen` (
`ID` int(11) NOT NULL,
`NotificationID` int(11) NOT NULL,
`UserID` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `not_confirmed_users`
--

CREATE TABLE `not_confirmed_users` (
`ID` int(11) NOT NULL,
`Username` text NOT NULL,
`Password` text NOT NULL,
`Email` text NOT NULL,
`PublicID` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `todo_categories`
--

CREATE TABLE `todo_categories` (
`ID` int NOT NULL,
`UserID` int NOT NULL,
`ID` int(11) NOT NULL,
`UserID` int(11) NOT NULL,
`Name` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

Expand All @@ -43,14 +80,14 @@ CREATE TABLE `todo_categories` (
--

CREATE TABLE `todo_tasks` (
`ID` int NOT NULL,
`UserID` int NOT NULL,
`CategoryID` int NOT NULL,
`TypeID` int NOT NULL,
`StateID` int NOT NULL DEFAULT '0',
`ID` int(11) NOT NULL,
`UserID` int(11) NOT NULL,
`CategoryID` int(11) NOT NULL,
`TypeID` int(11) NOT NULL,
`StateID` int(11) NOT NULL DEFAULT 0,
`Description` text NOT NULL,
`Date` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

Expand All @@ -59,10 +96,10 @@ CREATE TABLE `todo_tasks` (
--

CREATE TABLE `todo_types` (
`ID` int NOT NULL,
`UserID` int NOT NULL,
`ID` int(11) NOT NULL,
`UserID` int(11) NOT NULL,
`Name` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

Expand All @@ -71,12 +108,11 @@ CREATE TABLE `todo_types` (
--

CREATE TABLE `users` (
`ID` int NOT NULL,
`ID` int(11) NOT NULL,
`Username` text NOT NULL,
`Password` text NOT NULL,
`Email` text NOT NULL,
`isAdmin` int NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
`Email` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

Expand All @@ -85,16 +121,23 @@ CREATE TABLE `users` (
--

CREATE TABLE `usersessions` (
`ID` int NOT NULL,
`UserID` int NOT NULL,
`ID` int(11) NOT NULL,
`UserID` int(11) NOT NULL,
`PrivateID` text NOT NULL,
`Expires` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
`Expires` int(11) NOT NULL,
`IP` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Indizes der exportierten Tabellen
--

--
-- Indizes für die Tabelle `not_confirmed_users`
--
ALTER TABLE `not_confirmed_users`
ADD PRIMARY KEY (`ID`);

--
-- Indizes für die Tabelle `todo_categories`
--
Expand All @@ -117,7 +160,8 @@ ALTER TABLE `todo_types`
-- Indizes für die Tabelle `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`ID`);
ADD PRIMARY KEY (`ID`),
ADD UNIQUE KEY `Username` (`Username`) USING HASH;

--
-- Indizes für die Tabelle `usersessions`
Expand All @@ -129,37 +173,43 @@ ALTER TABLE `usersessions`
-- AUTO_INCREMENT für exportierte Tabellen
--

--
-- AUTO_INCREMENT für Tabelle `not_confirmed_users`
--
ALTER TABLE `not_confirmed_users`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `todo_categories`
--
ALTER TABLE `todo_categories`
MODIFY `ID` int NOT NULL AUTO_INCREMENT;
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `todo_tasks`
--
ALTER TABLE `todo_tasks`
MODIFY `ID` int NOT NULL AUTO_INCREMENT;
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `todo_types`
--
ALTER TABLE `todo_types`
MODIFY `ID` int NOT NULL AUTO_INCREMENT;
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `users`
--
ALTER TABLE `users`
MODIFY `ID` int NOT NULL AUTO_INCREMENT;
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `usersessions`
--
ALTER TABLE `usersessions`
MODIFY `ID` int NOT NULL AUTO_INCREMENT;
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
1 change: 1 addition & 0 deletions public_html/assets/undraw/confirm.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions public_html/signup/confirmemail/index.html
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="Your todo list. Anywhere. At any time. On any device."
/>
<meta
name="keywords"
content="officr, todo, todo list, open-source, tasks"
/>
<title>officr Accounts - Account created</title>
<link rel="stylesheet" href="/style/style.css" />
<script src="/js/overlays.js"></script>
<script src="/js/cookies.js"></script>
<link
rel="shortcut icon"
href="/assets/logo_single.svg"
type="image/x-icon"
/>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta property="og:title" content="officr - Your todo list" />
<meta
property="og:image"
content="https://officr.gabrielheinzer.ch/assets/social_preview.jpg"
/>
<meta
property="og:description"
content="officr is a open-source todo software. It can be used for homework, familiy or many other things."
/>
<meta property="og:url" content="https://officr.gabrielheinzer.ch" />
<meta property="og:image:width" content="1354" />
<meta property="og:image:height" content="469" />
</head>
<body onload="setTimeout(setLoaderAsFinished, 1200); showCookieOverlay()">
{includeRes:"cookie-note.html"}
<div class="vertical-container">
<div class="horizontal-container">
<header>
<img
src="/assets/logo_with_text_light.svg"
alt="officr"
class="desktop-only"
/>
<img
src="/assets/logo_single.svg"
alt="officr"
class="mobile-only"
/>
</header>
</div>
<div class="main-content">
<div id="notfound_message" style="text-align: center">
<img
src="/assets/undraw/done.svg"
alt=""
class="undraw-img"
style="display: block; width: 60vw; max-height: 50vh"
/>
<h1 style="text-align: center">{label60}</h1>
<p style="text-align: center">{label62}</p>
<a
href="../../login/"
class="border-button"
style="display: inline-block"
>{label12}</a
>
</div>
</div>
</div>
{includeRes:"loader-overlay.html"}
</body>
</html>
8 changes: 1 addition & 7 deletions public_html/signup/created/index.html
Expand Up @@ -55,19 +55,13 @@
<div class="main-content">
<div id="notfound_message" style="text-align: center">
<img
src="/assets/undraw/done.svg"
src="/assets/undraw/confirm.svg"
alt=""
class="undraw-img"
style="display: block; width: 60vw; max-height: 50vh"
/>
<h1 style="text-align: center">{label60}</h1>
<p style="text-align: center">{label61}</p>
<a
href="../../login/"
class="border-button"
style="display: inline-block"
>Login</a
>
</div>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions server/httpd.js
Expand Up @@ -8,6 +8,7 @@ const {
session_verify,
getUserByID,
sessionDestroy,
confirmEmail,
} = require("./user_management");
const labels = require("./lang-specific-content");
const { exec } = require("child_process");
Expand Down Expand Up @@ -50,6 +51,7 @@ if (httpd_config.ssl.active) {
}

function serverOnRequest(req, res, ssl) {
req.url_full = req.url;
req.url = req.url.toString().split("?")[0];
const { headers } = req;
res.setHeader("Server", `officr HTTPD`);
Expand Down Expand Up @@ -154,6 +156,12 @@ function handleNormalRequest(
);
return;
}
if (req.url_full.match(/\/signup\/confirmemail\?id=.*/)) {
var privateID = req.url_full
.match(/\/signup\/confirmemail\?id=.*/)[0]
.replace("/signup/confirmemail?id=", "");
confirmEmail(privateID);
}
req.on("data", (data) => {
handleFormInput(data, req, res);
});
Expand Down
6 changes: 4 additions & 2 deletions server/lang-specific-content.js
Expand Up @@ -64,7 +64,8 @@ const labels = {
58: "Ihre Benachrichtigung wurde erfolgreich erstellt.",
59: "Als gelesen markieren",
60: "Dein Account wurde erstellt.",
61: "Du solltest eine E-Mail erhalten haben.",
61: "Du solltest eine E-Mail erhalten haben. Bevor du dich aber einloggen kannst, musst du deine E-Mailadresse mit dem Button im E-Mail bestätigen.",
62: "Du kannst dich nun anmelden.",
},
en: {
1: "Category",
Expand Down Expand Up @@ -127,7 +128,8 @@ const labels = {
58: "The notification was created successfully.",
59: "Mark as seen",
60: "Your account was created.",
61: "You should have received a e-mail",
61: "You should have received a e-mail. Before you can log in, you have to confirm your e-mail address with the button in the email.",
62: "You can sign in now.",
},
};

Expand Down

0 comments on commit 371d975

Please sign in to comment.