Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87812d02d3 | ||
|
|
1104280c0c | ||
|
|
2e829b281b | ||
|
|
7adeb41402 | ||
|
|
c7f3fb0e6e | ||
|
|
ccabdc580c | ||
|
|
0350b80cda | ||
|
|
2dac1598ff | ||
|
|
32109debfd | ||
|
|
e1928f7af9 | ||
|
|
cd7bc8427f |
@@ -2,3 +2,4 @@
|
||||
.idea
|
||||
node_modules
|
||||
package-lock.json
|
||||
/.idea/
|
||||
|
||||
@@ -4,7 +4,7 @@ COPY --chown=gradle:gradle /private/minis-backend /home/gradle/src
|
||||
WORKDIR /home/gradle/src
|
||||
RUN gradle buildFatJar --no-daemon
|
||||
|
||||
FROM node:18 as build_frontend
|
||||
FROM node:24 as build_frontend
|
||||
|
||||
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
|
||||
WORKDIR /home/node/app
|
||||
|
||||
@@ -8,8 +8,5 @@
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"dropzone-vue3": "^1.0.2",
|
||||
"rxjs": "^7.8.1"
|
||||
}
|
||||
"dependencies": {}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ fun Application.configureDatabases() {
|
||||
SchemaUtils.create(GottesdienstGroups)
|
||||
SchemaUtils.create(Gottesdienste)
|
||||
SchemaUtils.create(Marks)
|
||||
exec("ALTER TABLE MINISTRANTEN ALTER COLUMN birthday BIGINT NULL;")
|
||||
// TODO Add proper versioning and migration for database
|
||||
exec("ALTER TABLE MINISTRANTEN ALTER COLUMN birthday DROP NOT NULL;")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ fun Payload.mid() = getClaim("id").asInt()
|
||||
|
||||
|
||||
object Security {
|
||||
fun DEFAULT_EXPIRY() = Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24 * 14);
|
||||
fun DEFAULT_EXPIRY() = Date(System.currentTimeMillis() + 1000L * 60 * 60 * 24 * 40);
|
||||
|
||||
suspend fun authenticateUser(application: Application, username: String, password: String): Ministrant? {
|
||||
println("Username $username password $password")
|
||||
|
||||
@@ -3,6 +3,7 @@ package de.walamana.views
|
||||
import at.favre.lib.crypto.bcrypt.BCrypt
|
||||
import com.auth0.jwt.JWT
|
||||
import com.auth0.jwt.algorithms.Algorithm
|
||||
import de.walamana.models.Ministrant
|
||||
import de.walamana.models.MinistrantenDao
|
||||
import de.walamana.plugins.Security
|
||||
import de.walamana.plugins.getJWTEnvironment
|
||||
@@ -98,6 +99,28 @@ fun Route.configureAuthenticationRoutes() {
|
||||
|
||||
call.respond(hashMapOf("password" to newPassword))
|
||||
}
|
||||
post("refresh") {
|
||||
val principal = call.principal<JWTPrincipal>()!!
|
||||
val jwtEnv = application.getJWTEnvironment()
|
||||
val username = principal.payload.username()
|
||||
|
||||
val ministrant = if (username == "admin") {
|
||||
val allMinis = MinistrantenDao.allMinistranten().map { it.username }
|
||||
Ministrant(0, "admin", "", "admin", "admin", null, allMinis)
|
||||
} else {
|
||||
MinistrantenDao.getMinistrant(username) ?: return@post
|
||||
}
|
||||
|
||||
val newToken = Security.createToken(jwtEnv, ministrant)
|
||||
val expiry = Security.DEFAULT_EXPIRY().toGMTString()
|
||||
|
||||
call.response.header(
|
||||
"Set-Cookie",
|
||||
"token=$newToken; HttpOnly; Expires=$expiry"
|
||||
)
|
||||
|
||||
call.respond(AuthenticationResult(true, newToken, ministrant.privileges))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,3 +26,4 @@ coverage
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
/dev-dist/
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<link rel="apple-touch-icon" href="/minis_logo.png">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="Miniplan">
|
||||
<title>Miniplan App</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet" />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false"
|
||||
},
|
||||
"dependencies": {
|
||||
"crypto-js": "^4.2.0",
|
||||
"dropzone-vue3": "^1.0.2",
|
||||
"rxjs": "^7.8.1",
|
||||
"underscore": "^1.13.7",
|
||||
@@ -19,12 +20,15 @@
|
||||
"devDependencies": {
|
||||
"@tsconfig/node18": "^18.2.0",
|
||||
"@types/node": "^18.17.0",
|
||||
"@vite-pwa/assets-generator": "^1.0.2",
|
||||
"@vitejs/plugin-vue": "^4.2.3",
|
||||
"@vue/tsconfig": "^0.4.0",
|
||||
"less": "^4.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"typescript": "~5.1.6",
|
||||
"vite": "^4.4.6",
|
||||
"vue-tsc": "^1.8.6"
|
||||
"vite": "^5.4.0",
|
||||
"vite-plugin-pwa": "^1.3.0",
|
||||
"vue-tsc": "^3.3.7",
|
||||
"workbox-window": "^7.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 931 B |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 9.5 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 891 B |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 64 KiB |
@@ -6,6 +6,8 @@ import {onMounted, ref} from "vue";
|
||||
import {Auth} from "@/services/auth";
|
||||
import DialogHost from "@/components/dialog/DialogHost.vue";
|
||||
import {LoginService} from "@/services/LoginService";
|
||||
import {Dialogs} from "@/services/DialogService";
|
||||
import InstallPWADialog from "@/components/dialog/InstallPWADialog.vue";
|
||||
|
||||
let showPopup = ref(false)
|
||||
let loggedIn = ref(false)
|
||||
@@ -22,14 +24,51 @@ function print(){
|
||||
window.print()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
Auth.checkForToken()
|
||||
if (Auth.getToken()) {
|
||||
await Auth.refreshToken()
|
||||
}
|
||||
})
|
||||
|
||||
LoginService.subject.subscribe(() => {
|
||||
showPopup.value = true
|
||||
})
|
||||
|
||||
const installEvent = ref<Event>()
|
||||
|
||||
window.addEventListener('beforeinstallprompt', (e) => {
|
||||
e.preventDefault()
|
||||
console.log("beforeinstallprompt")
|
||||
installEvent.value = e
|
||||
scheduleInstallDialog()
|
||||
})
|
||||
|
||||
function scheduleInstallDialog() {
|
||||
if (isPwa()) return
|
||||
if (localStorage.getItem('installPromptDismissed')) return
|
||||
if (!installEvent.value) return
|
||||
|
||||
Dialogs.createDialog(InstallPWADialog, {
|
||||
onPositive(dontShowAgain: boolean) {
|
||||
if (dontShowAgain) localStorage.setItem('installPromptDismissed', 'true')
|
||||
;(installEvent.value as any).prompt()
|
||||
},
|
||||
onNegative(dontShowAgain: boolean) {
|
||||
if (dontShowAgain) localStorage.setItem('installPromptDismissed', 'true')
|
||||
},
|
||||
onDismiss() {}
|
||||
}, {})
|
||||
}
|
||||
|
||||
function isPwa() {
|
||||
return window.matchMedia('(display-mode: standalone)').matches
|
||||
}
|
||||
|
||||
window.addEventListener('appinstalled', () => {
|
||||
localStorage.setItem('installPromptDismissed', 'true')
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
|
Before Width: | Height: | Size: 276 B After Width: | Height: | Size: 58 KiB |
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
import {ref} from "vue";
|
||||
import Dialog from "@/components/dialog/Dialog.vue";
|
||||
import type {DialogControls} from "@/components/dialog/dialog";
|
||||
|
||||
interface InstallPWADialogProps extends DialogControls {
|
||||
}
|
||||
|
||||
defineProps<InstallPWADialogProps>()
|
||||
|
||||
const dontShowAgain = ref<boolean>(false)
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<Dialog class="dialog">
|
||||
<h3 style="margin-bottom: 10px; display: flex; gap: 1rem; align-items: center">
|
||||
Zum Startbildschirm hinzufügen
|
||||
</h3>
|
||||
<p style="line-height: 1.7rem">
|
||||
Dein Miniplan kann jetzt auf Ihrem Gerät installiert werden, um schnell und einfach darauf zuzugreifen.
|
||||
</p>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" v-model="dontShowAgain" />
|
||||
Nicht mehr anzeigen
|
||||
</label>
|
||||
<div class="buttons">
|
||||
<button @click="onNegative(dontShowAgain)" class="dismiss">Später</button>
|
||||
<button @click="onPositive(dontShowAgain)" ><i>browser_updated</i>Jetzt hinzufügen</button>
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
</template>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
.dialog {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
width: 500px
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 16px;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
display: flex;
|
||||
justify-content: end;
|
||||
margin-top: 20px;
|
||||
|
||||
.dismiss {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -4,6 +4,19 @@ import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
|
||||
import { registerSW } from 'virtual:pwa-register'
|
||||
|
||||
registerSW({
|
||||
onNeedRefresh() {
|
||||
if (confirm('New content available. Reload?')) {
|
||||
window.location.reload()
|
||||
}
|
||||
},
|
||||
onOfflineReady() {
|
||||
console.log('App ready to work offline')
|
||||
}
|
||||
})
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
app.use(router)
|
||||
|
||||
@@ -71,6 +71,30 @@ export namespace Auth {
|
||||
}
|
||||
}
|
||||
|
||||
export async function refreshToken(): Promise<boolean> {
|
||||
const token = getToken()
|
||||
if (!token) return false
|
||||
|
||||
return api("/auth/refresh", "POST").then(res => {
|
||||
if (res.status == 200) {
|
||||
return res.json().then(data => {
|
||||
if (data.success) {
|
||||
setToken(data.token ?? "")
|
||||
const payload = parseJwt(data.token)
|
||||
loggedIn = true
|
||||
user = payload.username
|
||||
privileges = payload.privileges
|
||||
privileges.push(user)
|
||||
loggedInSubject.next(true)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
return false
|
||||
}).catch(() => false)
|
||||
}
|
||||
|
||||
function parseJwt (token) {
|
||||
var base64Url = token.split('.')[1];
|
||||
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
||||
|
||||
@@ -2,11 +2,75 @@ import { fileURLToPath, URL } from 'node:url'
|
||||
|
||||
import {defineConfig} from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import {VitePWA} from 'vite-plugin-pwa'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
export default defineConfig(({mode}) => (
|
||||
{
|
||||
plugins: [
|
||||
vue(),
|
||||
VitePWA({
|
||||
registerType: 'autoUpdate',
|
||||
includeAssets: ['favicon.ico', 'minis_logo.png'],
|
||||
manifest: {
|
||||
name: 'Miniplan App',
|
||||
short_name: 'Miniplan',
|
||||
description: 'Lade deinen Miniplan direkt auf dein Handy. So hast du den Miniplan jederzeit und schnell erreichbar.',
|
||||
theme_color: '#ffffff',
|
||||
background_color: '#ffffff',
|
||||
display: 'standalone',
|
||||
scope: '/',
|
||||
start_url: '/',
|
||||
screenshots: [
|
||||
{
|
||||
src: 'screenshot1.png',
|
||||
sizes: '505x710',
|
||||
type: 'image/png',
|
||||
form_factor: "narrow",
|
||||
label: "Miniplan Liste"
|
||||
},
|
||||
{
|
||||
src: 'screenshot2.png',
|
||||
sizes: '505x711',
|
||||
type: 'image/png',
|
||||
form_factor: "narrow",
|
||||
label: "Miniplan Tabelle"
|
||||
},
|
||||
{
|
||||
src: "screenshot3.png",
|
||||
sizes: '1003x709',
|
||||
type: 'image/png',
|
||||
form_factor: "wide",
|
||||
label: "Miniplan Tabelle"
|
||||
}
|
||||
],
|
||||
icons: [
|
||||
{
|
||||
src: "pwa-64x64.png",
|
||||
sizes: "64x64",
|
||||
type: "image/png"
|
||||
},
|
||||
{
|
||||
src: "pwa-192x192.png",
|
||||
sizes: "192x192",
|
||||
type: "image/png"
|
||||
},
|
||||
{
|
||||
src: "pwa-512x512.png",
|
||||
sizes: "512x512",
|
||||
type: "image/png"
|
||||
},
|
||||
{
|
||||
src: "maskable-icon-512x512.png",
|
||||
sizes: "512x512",
|
||||
type: "image/png",
|
||||
purpose: "maskable"
|
||||
}
|
||||
]
|
||||
},
|
||||
devOptions: {
|
||||
enabled: mode === "development"
|
||||
}
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
@@ -14,3 +78,4 @@ export default defineConfig({
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||