diff --git a/software/backend/data/accounts.json b/software/backend/data/accounts.json
index 8c312ec..54030e0 100644
--- a/software/backend/data/accounts.json
+++ b/software/backend/data/accounts.json
@@ -4,6 +4,7 @@
"id": 0,
"username": "hagemeister93",
"password": "Xjt3qb5t",
+ "email": "hagemeister93@gmail.com",
"firstName": "Laurin",
"lastName": "Hagemeister",
"addresses": [
@@ -28,6 +29,7 @@
"id": 1,
"username": "katjaStoiber",
"password": "target123",
+ "email": "k.stoiber@uni-hannover.de",
"firstName": "Katja",
"lastName": "Stoiber",
"addresses": [
@@ -52,6 +54,7 @@
"id": 2,
"username": "oetkerohnek",
"password": "iloveyou",
+ "email": "oetker30625@gmx.com",
"firstName": "Luna",
"lastName": "Oeter",
"addresses": [
@@ -83,6 +86,7 @@
"id": 3,
"username": "duranduran",
"password": "H4nn0ver",
+ "email": "dduran@hannover.de",
"firstName": "Jürgen",
"lastName": "Durand",
"addresses": [
@@ -114,6 +118,7 @@
"id": 4,
"username": "guitarhero",
"password": "gwerty123",
+ "email": "guitarheroFurti@gmail.com",
"firstName": "Frederik",
"lastName": "Furtwängler",
"addresses": [
@@ -138,6 +143,7 @@
"id": 5,
"username": "herbstMareike",
"password": "qhsrbpgrs",
+ "email": "m.herbst@uni-hannover.de",
"firstName": "Mareike",
"lastName": "Herbst",
"addresses": [
@@ -162,6 +168,7 @@
"id": 6,
"username": "seibertmitb",
"password": "{jkz+WvQe",
+ "email": "janna-seibert@yahoo.com",
"firstName": "Janna",
"lastName": "Seibert",
"addresses": [
diff --git a/software/backend/models/account.model.ts b/software/backend/models/account.model.ts
index 4ea3991..aa5b59e 100644
--- a/software/backend/models/account.model.ts
+++ b/software/backend/models/account.model.ts
@@ -13,6 +13,10 @@ export class Account extends Model {
@Column
password: string
+ @Unique
+ @Column
+ email: string
+
@Column
firstName: string = ""
diff --git a/software/backend/routes/account.routes.ts b/software/backend/routes/account.routes.ts
index c35466d..56dd252 100644
--- a/software/backend/routes/account.routes.ts
+++ b/software/backend/routes/account.routes.ts
@@ -78,11 +78,29 @@ account.post("/", (req: Request, res: Response) => {
})
account.patch("/", (req: Request, res: Response) => {
+ console.log(req.body)
+
Account.update(req.body,
{
where: { id: req.body.id }
})
- .then(account => {
+ .then(async account => {
+ for (let payment of req.body.payments) {
+ await Payment.update(payment,
+ {
+ where: { id: payment.id }
+ }
+ )
+ }
+
+ for (let address of req.body.addresses) {
+ await Address.update(address,
+ {
+ where: { id: address.id }
+ }
+ )
+ }
+
// Status: 200 OK
res.status(200).json(account)
})
diff --git a/software/src/App.vue b/software/src/App.vue
index 8bae8fe..28e0c1b 100644
--- a/software/src/App.vue
+++ b/software/src/App.vue
@@ -7,10 +7,12 @@ import navigationItems from './components/navigationItems.vue';
import { useProductStore } from './data/stores/productStore';
import { useCategoryStore } from './data/stores/categoryStore';
import { usePreferencesStore } from './data/stores/preferencesStore';
+import { useFeedbackStore } from './data/stores/feedbackStore';
const preferencesStore = usePreferencesStore()
const productStore = useProductStore()
const categoryStore = useCategoryStore()
+const feedbackStore = useFeedbackStore()
const theme = useTheme()
const navRail = ref(vuetify.display.mobile)
@@ -38,6 +40,26 @@ watch(() => preferencesStore.language, () => {
+
+
+
+ {{ feedbackStore.title }}
+
+
+
+
+
+
diff --git a/software/src/components/alertBanner.vue b/software/src/components/alertBanner.vue
deleted file mode 100644
index b83d2da..0000000
--- a/software/src/components/alertBanner.vue
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
- {{ feedbackStore.title }}
-
-
-
-
-
\ No newline at end of file
diff --git a/software/src/data/models/accountModel.ts b/software/src/data/models/accountModel.ts
index 64293b0..bd4ca63 100644
--- a/software/src/data/models/accountModel.ts
+++ b/software/src/data/models/accountModel.ts
@@ -6,6 +6,7 @@ export class AccountModel {
id: number
username: string = ""
password: string = ""
+ email: string = ""
firstName: string = ""
lastName: string = ""
addresses: Array = [ new AddressModel() ]
diff --git a/software/src/locales/de.json b/software/src/locales/de.json
index b7808d4..5c87fd5 100644
--- a/software/src/locales/de.json
+++ b/software/src/locales/de.json
@@ -71,7 +71,8 @@
"masterData": "Stammdaten",
"noAddresses": "Keine Adressen gefunden",
"noPayments": "Keine Bezahlarten gefunden",
- "newPayment": "New Payment"
+ "newPayment": "New Payment",
+ "email": "E-Mail-Adresse"
},
"bannerMessages": {
"loginSuccessful": "Login erfolgreich!",
@@ -127,5 +128,10 @@
"noOrders": "Keine Bestellungen gefunden",
"noOrdersText": "Bisher wurden keine Bestellungen von diesem Account getätigt. Gehe zum Warenkorb und bestelle!",
"add": "Hinzufügen",
- "remove": "Entfernen"
+ "remove": "Entfernen",
+ "emailIsNotValid": "Ungültige E-Mail Addresse",
+ "emailRequired": "E-Mail-Adresse benötigt",
+ "tooMuchChars": "Zu lang",
+ "digitsAtStartNeeded": "Muss mit einer Zahl beginnen",
+ "wrongIban": "Falsches IBAN Format, nur deutsche IBAN-Nummern erlaubt!"
}
diff --git a/software/src/locales/en.json b/software/src/locales/en.json
index 4a7910f..8bf7b3b 100644
--- a/software/src/locales/en.json
+++ b/software/src/locales/en.json
@@ -71,7 +71,8 @@
"masterData": "Master data",
"noAddresses": "No Addresses found",
"noPayments": "No payments found",
- "newPayment": "New Payment"
+ "newPayment": "New Payment",
+ "email": "E-Mail address"
},
"bannerMessages": {
"loginSuccessful": "Login erfolgreich!",
@@ -127,5 +128,10 @@
"noOrders": "No orders found",
"noOrdersText": "There are no orders with this account until now. Go to the basket page and order something!",
"add": "Add",
- "remove": "Remove"
+ "remove": "Remove",
+ "emailIsNotValid": "E-mail must be valid",
+ "emailRequired": "E-Mail is required",
+ "tooMuchChars": "Too long",
+ "digitsAtStartNeeded": "Has to beginn with a number",
+ "wrongIban": "Wrong IBAN format, only German IBANs are allowed!"
}
diff --git a/software/src/pages/accountPage/accountDataCard.vue b/software/src/pages/accountPage/accountDataCard.vue
index 9d899ca..f324ee8 100644
--- a/software/src/pages/accountPage/accountDataCard.vue
+++ b/software/src/pages/accountPage/accountDataCard.vue
@@ -1,10 +1,51 @@
@@ -12,6 +53,15 @@ const accountStore = useAccountStore()
:title="$t('account.masterData')"
icon="mdi-account"
>
+
+
+
+
+
@@ -34,12 +85,14 @@ const accountStore = useAccountStore()
diff --git a/software/src/pages/accountPage/addressesCard.vue b/software/src/pages/accountPage/addressesCard.vue
index 5f0ca7c..8c5fe8d 100644
--- a/software/src/pages/accountPage/addressesCard.vue
+++ b/software/src/pages/accountPage/addressesCard.vue
@@ -3,6 +3,8 @@ import cardView from '@/components/cardView.vue';
import { useAccountStore } from '@/data/stores/accountStore';
import outlinedButton from '@/components/outlinedButton.vue';
import { AddressModel } from '@/data/models/addressModel';
+import { useFeedbackStore } from '@/data/stores/feedbackStore';
+import { getNumberStartRules, getPostalRules, getStringRules } from '@/scripts/validationRules';
const accountStore = useAccountStore()
@@ -27,12 +29,16 @@ const accountStore = useAccountStore()
@@ -42,12 +48,16 @@ const accountStore = useAccountStore()
diff --git a/software/src/pages/accountPage/paymentsCard.vue b/software/src/pages/accountPage/paymentsCard.vue
index 656929f..aa760c2 100644
--- a/software/src/pages/accountPage/paymentsCard.vue
+++ b/software/src/pages/accountPage/paymentsCard.vue
@@ -3,6 +3,7 @@ import cardView from '@/components/cardView.vue';
import { useAccountStore } from '@/data/stores/accountStore';
import outlinedButton from '@/components/outlinedButton.vue';
import { PaymentModel } from '@/data/models/paymentModel';
+import { getIbanRules, getStringRules } from '@/scripts/validationRules';
const accountStore = useAccountStore()
@@ -29,12 +30,14 @@ const accountStore = useAccountStore()
diff --git a/software/src/pages/basketPage/index.vue b/software/src/pages/basketPage/index.vue
index 7a7b6c4..bfc3181 100644
--- a/software/src/pages/basketPage/index.vue
+++ b/software/src/pages/basketPage/index.vue
@@ -1,7 +1,6 @@
-
-
-
-
-
-
-
+
diff --git a/software/src/pages/loginPage/loginForm.vue b/software/src/pages/loginPage/loginForm.vue
index c5d70fe..939f96c 100644
--- a/software/src/pages/loginPage/loginForm.vue
+++ b/software/src/pages/loginPage/loginForm.vue
@@ -9,10 +9,28 @@ const showRegisterCard = defineModel("showRegisterCard", { type: Boolean, defaul
const loginInProgress = ref(false)
const username = ref("duranduran")
const password = ref("H4nn0ver")
+const usernameWrong = ref(false)
+const passwordWrong = ref(false)
async function startLogin() {
loginInProgress.value = true
- await accountStore.login(username.value, password.value)
+ usernameWrong.value = false
+ passwordWrong.value = false
+
+ if (username.value == null || username.value.length == 0) {
+ usernameWrong.value = true
+ }
+
+ if (password.value == null || password.value.length == 0) {
+ passwordWrong.value = true
+ }
+
+ if (username.value != null && username.value.length > 0 &&
+ password.value != null && password.value.length > 0)
+ {
+ await accountStore.login(username.value, password.value)
+ }
+
loginInProgress.value = false
}
@@ -21,14 +39,26 @@ async function startLogin() {
-
+
-
+
diff --git a/software/src/pages/loginPage/registerForm.vue b/software/src/pages/loginPage/registerForm.vue
index 31ee220..edb63ca 100644
--- a/software/src/pages/loginPage/registerForm.vue
+++ b/software/src/pages/loginPage/registerForm.vue
@@ -4,90 +4,14 @@ import { ref } from 'vue';
import cardView from '@/components/cardView.vue';
import outlinedButton from '@/components/outlinedButton.vue';
import { useAccountStore } from '@/data/stores/accountStore';
-import { i18n } from '@/plugins/i18n';
import { useFeedbackStore } from '@/data/stores/feedbackStore';
+import { getEmailRules, getPasswordRules, getStringRules } from '@/scripts/validationRules';
const newUser = ref(new AccountModel())
const showRegisterCard = defineModel("showRegisterCard", { type: Boolean, default: false })
const accountStore = useAccountStore()
-const feedbackStore = useFeedbackStore()
const registerInProgress = ref(false)
-const stringRules = [
- value => {
- if (value) {
- return true
- } else {
- return feedbackStore.i18n.t('required')
- }
- },
- value => {
- if (/[^0-9]/.test(value)) {
- return true
- } else {
- return feedbackStore.i18n.t('noDigitsAllowed')
- }
- },
- value => {
- if (value?.length >= 4) {
- return true
- } else {
- return feedbackStore.i18n.t('notEnoughChars')
- }
- }
-]
-
-const passwordRules = [
- value => {
- if (value) {
- return true
- } else {
- return feedbackStore.i18n.t('required')
- }
- },
- value => {
- if (value?.length >= 8) {
- return true
- } else {
- return feedbackStore.i18n.t('passwordToShort')
- }
- }
-]
-
-const postalRules = [
- value => {
- if (/[0-9]/.test(value)) {
- return true
- } else {
- return feedbackStore.i18n.t('onlyDigitsAllowed')
- }
- },
- value => {
- if (value?.length == 5) {
- return true
- } else {
- return feedbackStore.i18n.t('notEnoughChars')
- }
- }
-]
-
-const numberRules = [
- value => {
- if (value) {
- return true
- } else {
- return feedbackStore.i18n.t('required')
- }
- },
- value => {
- if (/[0-9]/.test(value)) {
- return true
- } else {
- return feedbackStore.i18n.t('onlyDigitsAllowed')
- }
- },
-]
-
async function registerAccount() {
registerInProgress.value = true
@@ -97,7 +21,10 @@ async function registerAccount() {
-
+
+
+
@@ -124,60 +53,11 @@ async function registerAccount() {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/software/src/pages/preferencesPage/index.vue b/software/src/pages/preferencesPage/index.vue
index 5bf0665..062522a 100644
--- a/software/src/pages/preferencesPage/index.vue
+++ b/software/src/pages/preferencesPage/index.vue
@@ -1,13 +1,10 @@
-
-
diff --git a/software/src/pages/preferencesPage/systemSetup.vue b/software/src/pages/preferencesPage/systemSetup.vue
index ef10e0b..3377cce 100644
--- a/software/src/pages/preferencesPage/systemSetup.vue
+++ b/software/src/pages/preferencesPage/systemSetup.vue
@@ -25,10 +25,13 @@ getServerState()
})
async function resetDb() {
+ serverOnline.value = ServerStateEnum.PENDING
+
await resetDatabase()
.then(result => {
if (result.status == 200) {
feedbackStore.changeBanner(BannerStateEnum.DATABASERESETSUCCESSFUL)
+ serverOnline.value = ServerStateEnum.ONLINE
}
})
diff --git a/software/src/pages/productsPage/index.vue b/software/src/pages/productsPage/index.vue
index 8975f96..e7d0042 100644
--- a/software/src/pages/productsPage/index.vue
+++ b/software/src/pages/productsPage/index.vue
@@ -3,7 +3,6 @@ import productCard from "./productCard.vue"
import productDetails from "./productDetailsDialog.vue"
import { ref, watch } from "vue";
import { useProductStore } from "@/data/stores/productStore";
-import alertBanner from "@/components/alertBanner.vue";
import filterNavDrawer from "./filterNavDrawer.vue";
import { ProductModel } from '@/data/models/productModel';
@@ -24,12 +23,6 @@ watch(() => productStore.onlyDiscounts, async () => { productStore.filterProduct
-
-
-
-
-
-
{
+ if (value) {
+ return true
+ } else {
+ return feedbackStore.i18n.t('required')
+ }
+ },
+ value => {
+ if (/[^0-9]/.test(value)) {
+ return true
+ } else {
+ return feedbackStore.i18n.t('noDigitsAllowed')
+ }
+ },
+ value => {
+ if (value?.length >= 4) {
+ return true
+ } else {
+ return feedbackStore.i18n.t('notEnoughChars')
+ }
+ }
+ ]
+}
+
+/**
+ * Check a string for exact five digits length and only digits
+ *
+ * @returns Array of rules
+ */
+export function getPostalRules() {
+ const feedbackStore = useFeedbackStore()
+
+ return [
+ value => {
+ if (value?.length == 5) {
+ return true
+ } else if (value?.length < 5) {
+ return feedbackStore.i18n.t('notEnoughChars')
+ } else {
+ return feedbackStore.i18n.t('tooMuchChars')
+ }
+ },
+ value => {
+ if (value?.length == 5) {
+ return true
+ } else {
+ return feedbackStore.i18n.t('notEnoughChars')
+ }
+ },
+ value => {
+ if (/^\d+$/.test(value)) {
+ return true
+ } else {
+ return feedbackStore.i18n.t('onlyDigitsAllowed')
+ }
+ }
+ ]
+}
+
+/**
+ * Check a string for not empty and first char is a digit
+ *
+ * @returns Array of rules
+ */
+export function getNumberStartRules() {
+ const feedbackStore = useFeedbackStore()
+
+ return [
+ value => {
+ if (value) {
+ return true
+ } else {
+ return feedbackStore.i18n.t('required')
+ }
+ },
+ value => {
+ if (/^\d/.test(value)) {
+ return true
+ } else {
+ return feedbackStore.i18n.t('digitsAtStartNeeded')
+ }
+ },
+ ]
+}
+
+/**
+ * Check a string for email format
+ *
+ * @returns Array of rules
+ */
+export function getEmailRules() {
+ const feedbackStore = useFeedbackStore()
+
+ return [
+ value => {
+ if (value) return true
+
+ return feedbackStore.i18n.t('emailRequired')
+ },
+ value => {
+ if (/.+@.+\..+/.test(value)) return true
+
+ return feedbackStore.i18n.t('emailIsNotValid')
+ },
+ ]
+}
+
+/**
+ * Check a string for a good password
+ *
+ * @returns Array of rules
+ */
+export function getPasswordRules() {
+ const feedbackStore = useFeedbackStore()
+
+ return [
+ value => {
+ if (value) {
+ return true
+ } else {
+ return feedbackStore.i18n.t('required')
+ }
+ },
+ value => {
+ if (value?.length >= 8) {
+ return true
+ } else {
+ return feedbackStore.i18n.t('passwordToShort')
+ }
+ }
+ ]
+}
+
+/**
+ * Check a string for IBAN format
+ *
+ * @returns Array of rules
+ */
+export function getIbanRules() {
+ const feedbackStore = useFeedbackStore()
+
+ return [
+ value => {
+ if (value) {
+ return true
+ } else {
+ return feedbackStore.i18n.t('required')
+ }
+ },
+ value => {
+ if (/[A-Z]{2}[0-9]{2}(?:[ ]?[0-9]{4}){4}(?!(?:[ ]?[0-9]){3})(?:[ ]?[0-9]{1,2})?/.test(value)) {
+ return true
+ } else {
+ return feedbackStore.i18n.t('wrongIban')
+ }
+ }
+ ]
+}
\ No newline at end of file