diff --git a/.gitignore b/.gitignore
index 227a76a..3f19c4d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,4 +31,5 @@ coverage
# Build and package files/folders
build
-*.sqlite
\ No newline at end of file
+*.sqlite
+out/
\ No newline at end of file
diff --git a/software/backend/data/accounts.json b/software/backend/data/accounts.json
index eb1a498..7f4d6ca 100644
--- a/software/backend/data/accounts.json
+++ b/software/backend/data/accounts.json
@@ -4,7 +4,10 @@
"id": 0,
"username": "hagemeister93",
"password": "Xjt3qb5t",
- "address": "Laportestraße 22, 30449 Hannover",
+ "street": "Laportestraße",
+ "houseNumber": 22,
+ "postalCode": 30449,
+ "city": "Hannover",
"firstName": "Laurin",
"lastName": "Hagemeister"
},
@@ -12,7 +15,10 @@
"id": 1,
"username": "katjaStoiber",
"password": "target123",
- "address": "Gustav-Adolf-Straße 30, 30167 Hannover",
+ "street": "Gustav-Adolf-Straße",
+ "houseNumber": 30,
+ "postalCode": 30167,
+ "city": "Hannover",
"firstName": "Katja",
"lastName": "Stoiber"
},
@@ -20,7 +26,10 @@
"id": 2,
"username": "oetkerohnek",
"password": "iloveyou",
- "address": "Eckermannstraße 1, 30625 Hannover",
+ "street": "Eckermannstraße",
+ "houseNumber": 1,
+ "postalCode": 30625,
+ "city": "Hannover",
"firstName": "Luna",
"lastName": "Oeter"
},
@@ -28,7 +37,10 @@
"id": 3,
"username": "duranduran",
"password": "H4nn0ver",
- "address": "Schlägerstraße 36, 30171 Hannover",
+ "street": "Schlägerstraße",
+ "houseNumber": 36,
+ "postalCode": 30171,
+ "city": "Hannover",
"firstName": "Jürgen",
"lastName": "Durand"
},
@@ -36,7 +48,10 @@
"id": 4,
"username": "guitarhero",
"password": "gwerty123",
- "address": "Steinmetzstraße 12, 30163 Hannover",
+ "street": "Steinmetzstraße",
+ "houseNumber": 12,
+ "postalCode": 30163,
+ "city": "Hannover",
"firstName": "Frederik",
"lastName": "Furtwängler"
},
@@ -44,7 +59,10 @@
"id": 5,
"username": "herbstMareike",
"password": "qhsrbpgrs",
- "address": "Allerweg 33, 30851 Langenhagen",
+ "street": "Allerweg",
+ "houseNumber": 33,
+ "postalCode": 30851,
+ "city": "Langenhagen",
"firstName": "Mareike",
"lastName": "Herbst"
},
@@ -52,7 +70,10 @@
"id": 6,
"username": "seibertmitb",
"password": "{jkz+WvQe",
- "address": "Marktstraße 26, 30880 Laatzen",
+ "street": "Marktstraße",
+ "houseNumber": 26,
+ "postalCode": 30880,
+ "city": "Laatzen",
"firstName": "Janna",
"lastName": "Seibert"
}
diff --git a/software/backend/database.ts b/software/backend/database.ts
index 5f38cdb..fbe9012 100644
--- a/software/backend/database.ts
+++ b/software/backend/database.ts
@@ -23,7 +23,7 @@ export const sequelize = new Sequelize({
export function startDatabase() {
// Create database and tables
- sequelize.sync({ force: false })
+ sequelize.sync({ force: true })
.then(() => {
console.log(`Database & tables created!`)
})
diff --git a/software/backend/models/account.model.ts b/software/backend/models/account.model.ts
index 04683d7..b693ac0 100644
--- a/software/backend/models/account.model.ts
+++ b/software/backend/models/account.model.ts
@@ -1,23 +1,33 @@
-import { Table, Column, Model, HasMany } from 'sequelize-typescript';
+import { Table, Column, Model, HasMany, Unique } from 'sequelize-typescript';
import { Order } from './order.model';
@Table
export class Account extends Model {
+ @Unique
@Column
username: string
@Column
password: string
- @Column
- address: string
-
@Column
firstName: string
@Column
lastName: string
+ @Column
+ street: string
+
+ @Column
+ houseNumber: number
+
+ @Column
+ postalCode: number
+
+ @Column
+ city: string
+
// Relations
@HasMany(() => Order)
orders: Order[]
diff --git a/software/backend/routes/account.routes.ts b/software/backend/routes/account.routes.ts
index 3271de6..897eec3 100644
--- a/software/backend/routes/account.routes.ts
+++ b/software/backend/routes/account.routes.ts
@@ -1,12 +1,36 @@
import { Router, Request, Response, NextFunction } from "express";
import { Account } from "../models/account.model";
+import { validateString } from "../scripts/validateHelper";
export const account = Router()
-account.get("/", (req: Request, res: Response, next: NextFunction)=> {
+// Request all user from the database
+account.get("/", (req: Request, res: Response, next: NextFunction) => {
Account.findAll()
.then(accounts => {
res.json(accounts)
})
.catch(next)
+})
+
+// Creating a new user
+account.post("/", (req: Request, res: Response, next: NextFunction) => {
+ if (!validateString(req.body.username, 4))
+ {
+ res.status(400).send({ error: "Username too short!" })
+ }
+ else if (!validateString(req.body.password, 8))
+ {
+ res.status(400).send({ error: "Password too short!" })
+ }
+ else
+ {
+ Account.create(req.body)
+ .then(account => {
+ res.json(account)
+ res.status(200).send()
+ }).catch(reason => {
+ res.status(400).send({ error: reason })
+ })
+ }
})
\ No newline at end of file
diff --git a/software/backend/routes/category.routes.ts b/software/backend/routes/category.routes.ts
index 5c563dd..0a3abd9 100644
--- a/software/backend/routes/category.routes.ts
+++ b/software/backend/routes/category.routes.ts
@@ -13,7 +13,6 @@ category.get("/", (req: Request, res: Response, next: NextFunction) => {
category.post("/", (req: Request, res: Response, next: NextFunction) => {
try {
- console.log(req.body)
const category = Category.create(req.body)
res.status(201).json(category)
} catch (e) {
diff --git a/software/backend/scripts/categories.json b/software/backend/scripts/categories.json
deleted file mode 100644
index 3918073..0000000
--- a/software/backend/scripts/categories.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "id": 1,
- "title": "Hello World",
- "completed": false
-}
\ No newline at end of file
diff --git a/software/backend/scripts/validateHelper.ts b/software/backend/scripts/validateHelper.ts
new file mode 100644
index 0000000..a72440f
--- /dev/null
+++ b/software/backend/scripts/validateHelper.ts
@@ -0,0 +1,16 @@
+/**
+ * Validates a string for undefined and length
+ *
+ * @param string String to prove
+ * @param length Minimal length of string
+ *
+ * @returns True if valid
+ */
+export function validateString(string: string, length: number = 0) : boolean {
+ if (string != undefined) {
+ if (string.length >= length)
+ return true
+ }
+
+ return false
+}
\ No newline at end of file
diff --git a/software/src/data/models/accountModel.ts b/software/src/data/models/accountModel.ts
new file mode 100644
index 0000000..b3890aa
--- /dev/null
+++ b/software/src/data/models/accountModel.ts
@@ -0,0 +1,13 @@
+export class AccountModel {
+ id: number
+ username: string = ""
+ password: string = ""
+ street: string = ""
+ houseNumber: number = 0
+ postalCode: number = 0
+ city: string = ""
+ firstName: string = ""
+ lastName: string = ""
+ createdAt: string = ""
+ updatedAt: string = ""
+}
\ No newline at end of file
diff --git a/software/src/locales/english.json b/software/src/locales/english.json
index 443360c..54e02e9 100644
--- a/software/src/locales/english.json
+++ b/software/src/locales/english.json
@@ -36,7 +36,7 @@
"username": "Username",
"password": "Password",
"login": "Login",
- "noAccountRegister": "No Account? Register now!",
+ "noAccountRegister": "Create new Account!",
"register": "Create Account",
"userInfo": {
"firstName": "First Name",
@@ -45,5 +45,6 @@
"houseNumber": "House Number",
"postalCode": "Postal Code",
"city": "City"
- }
+ },
+ "backToLogin": "Back to Login"
}
\ No newline at end of file
diff --git a/software/src/locales/german.json b/software/src/locales/german.json
index 237d1e4..f3171f4 100644
--- a/software/src/locales/german.json
+++ b/software/src/locales/german.json
@@ -36,7 +36,7 @@
"username": "Username",
"password": "Passwort",
"login": "Login",
- "noAccountRegister": "Noch keinen Account? Jetzt anmelden!",
+ "noAccountRegister": "Neuen Account erstellen!",
"register": "Account erstellen",
"userInfo": {
"firstName": "Vorname",
@@ -45,5 +45,6 @@
"houseNumber": "Hausnummer",
"postalCode": "Postleitzahl",
"city": "Stadt"
- }
+ },
+ "backToLogin": "Zurück zum Login"
}
\ No newline at end of file
diff --git a/software/src/pages/loginPage/index.vue b/software/src/pages/loginPage/index.vue
index 6de2249..9c40b08 100644
--- a/software/src/pages/loginPage/index.vue
+++ b/software/src/pages/loginPage/index.vue
@@ -2,18 +2,35 @@
import { ref } from 'vue';
import loginForm from './loginForm.vue';
import registerForm from './registerForm.vue';
+import BannerModel from '@/data/models/bannerModel';
+import alertBanner from '@/components/alertBanner.vue';
-const showRegisterDialog = ref(false)
+const showRegisterCard = ref(false)
+const banner = ref(new BannerModel())
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/software/src/pages/loginPage/loginForm.vue b/software/src/pages/loginPage/loginForm.vue
index e01348c..192d29f 100644
--- a/software/src/pages/loginPage/loginForm.vue
+++ b/software/src/pages/loginPage/loginForm.vue
@@ -1,5 +1,5 @@
@@ -16,19 +16,15 @@ const showRegisterDialog = defineModel("showRegisterDialog", { type: Boolean, de
-
-
-
-
- {{ $t('login') }}
-
-
-
-
+
+
{{ $t('noAccountRegister') }}
-
+
+ {{ $t('login') }}
+
+
\ No newline at end of file
diff --git a/software/src/pages/loginPage/registerForm.vue b/software/src/pages/loginPage/registerForm.vue
index 281728b..4cc41ce 100644
--- a/software/src/pages/loginPage/registerForm.vue
+++ b/software/src/pages/loginPage/registerForm.vue
@@ -1,54 +1,107 @@
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
- {{ $t('register') }}
+ {{ $t('backToLogin') }}
+
+ {{ $t('register') }}
-
+
\ No newline at end of file