new page layout

This commit is contained in:
2025-12-10 00:58:38 +00:00
parent 21eeb351c8
commit b6c9d8d80f
13 changed files with 111 additions and 34 deletions

View File

@@ -135,6 +135,28 @@ func (store *Store) DeleteUser(ctx *gin.Context) {
return return
} }
store.DB.Delete(&user) tx := store.DB.Delete(&user)
if tx.Error != nil {
ctx.JSON(http.StatusInternalServerError, tx.Error.Error())
return
}
ctx.SetCookie(
"access_token",
"",
-1,
store.Auth.Config.Endpoint,
store.Auth.Config.Domain,
true, true,
)
ctx.SetCookie(
"refresh_token",
"",
-1,
store.Auth.Config.Endpoint,
store.Auth.Config.Domain,
true, true,
)
ctx.JSON(http.StatusOK, user) ctx.JSON(http.StatusOK, user)
} }

View File

@@ -4,8 +4,8 @@ import "gorm.io/gorm"
type Post struct { type Post struct {
gorm.Model // includes ID, CreatedAt, UpdatedAt, DeletedAt gorm.Model // includes ID, CreatedAt, UpdatedAt, DeletedAt
Title string `gorm:"not null"` Title string `gorm:"not null" json:"title"`
AuthorID uint AuthorID uint `json:"-"`
Author User `gorm:"foreignKey:AuthorID"` Author User `gorm:"foreignKey:AuthorID" json:"author"`
Content string Content string `json:"content"`
} }

View File

@@ -4,7 +4,7 @@ import "gorm.io/gorm"
type User struct { type User struct {
gorm.Model // includes ID, CreatedAt, UpdatedAt, DeletedAt gorm.Model // includes ID, CreatedAt, UpdatedAt, DeletedAt
Username string `gorm:"uniqueIndex"` Username string `gorm:"uniqueIndex" json:"username"`
Password []byte `json:"-"` Password []byte `json:"-"`
Admin bool Admin bool `json:"admin"`
} }

View File

@@ -1,13 +1,26 @@
<script setup> <script setup>
import { ref, onMounted } from "vue"; import { ref, onMounted, computed } from "vue";
import { useAuthStore } from "@/stores/auth";
const loggedIn = ref(false); const auth = useAuthStore();
const username = ref("");
const password = ref("");
const loggedIn = computed(() => Object.keys(auth.user.ID || {}).length > 0);
function handleLogin() {
auth.logIn(username.value, password.value);
}
</script> </script>
<template> <template>
<div v-if="!loggedIn"> <div v-if="loggedIn">
<p>{{ auth.user.ID }}</p>
<p>{{ auth.user.username }}</p>
</div>
<div v-else>
<h1>login</h1> <h1>login</h1>
<textarea>Username</textarea> <textarea v-model="username"></textarea>
<textarea>Password</textarea> <textarea type="password" v-model="password"></textarea>
<button @click="handleLogin">Log In</button>
</div> </div>
</template> </template>

View File

@@ -1,3 +1,11 @@
<template> <template>
<div></div> <div>
<img src="/img/epic.jpeg" />
</div>
</template> </template>
<style scoped>
img {
width: 100%;
}
</style>

View File

@@ -18,5 +18,13 @@ onMounted(() => {
</script> </script>
<template> <template>
<div></div> <div>
<img src="/img/epic.jpeg" />
</div>
</template> </template>
<style scoped>
img {
width: 100%;
}
</style>

View File

@@ -1,3 +1,11 @@
<template> <template>
<div></div> <div>
<img src="/img/epic.jpeg" />
</div>
</template> </template>
<style scoped>
img {
width: 100%;
}
</style>

View File

@@ -6,6 +6,14 @@
<p>Hello</p> <p>Hello</p>
<p>Hello</p> <p>Hello</p>
<p>Hello</p> <p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
<p>Hello</p>
</div> </div>
</div> </div>
</template> </template>

View File

@@ -3,19 +3,19 @@
<RouterLink to="/cv"> <RouterLink to="/cv">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" /> <img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
</RouterLink> </RouterLink>
<RouterLink to="/login"> <RouterLink to="/admin">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" /> <img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
</RouterLink> </RouterLink>
<RouterLink to="/login"> <RouterLink to="/admin">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" /> <img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
</RouterLink> </RouterLink>
<RouterLink to="/login"> <RouterLink to="/admin">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" /> <img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
</RouterLink> </RouterLink>
<RouterLink to="/login"> <RouterLink to="/admin">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" /> <img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
</RouterLink> </RouterLink>
<RouterLink to="/login"> <RouterLink to="/admin">
<img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" /> <img src="/img/stamps/BC7BDBB9-36FF-4DBE-B825-3603BFE00BE0.gif" />
</RouterLink> </RouterLink>
</div> </div>

View File

@@ -10,9 +10,7 @@ let idx = 0;
async function fetchRecent() { async function fetchRecent() {
try { try {
const res = await axios.get( const res = await axios.get("/api/spotify/recent");
"https://adam-french.co.uk/api/spotify/recent",
);
songs = res.data; songs = res.data;
fetched.value = true; fetched.value = true;
song.value = songs[0]; song.value = songs[0];

View File

@@ -1,3 +1,11 @@
<template> <template>
<div></div> <div>
<img src="/img/epic.jpeg" />
</div>
</template> </template>
<style scoped>
img {
width: 100%;
}
</style>

View File

@@ -4,6 +4,7 @@ import axios from "axios";
export const useAuthStore = defineStore("auth", () => { export const useAuthStore = defineStore("auth", () => {
const user = ref({}); const user = ref({});
checkToken();
function logOut() { function logOut() {
user.value = {}; user.value = {};
@@ -15,6 +16,7 @@ export const useAuthStore = defineStore("auth", () => {
username, username,
password, password,
}); });
user.value = res.data;
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} }
@@ -34,7 +36,9 @@ export const useAuthStore = defineStore("auth", () => {
const res = await axios.get("/api/auth/check"); const res = await axios.get("/api/auth/check");
user.value = res.data; user.value = res.data;
} catch (err) { } catch (err) {
console.log(err); user.value = {};
} }
} }
return { user, checkToken, logIn, refreshToken, logOut };
}); });

View File

@@ -13,15 +13,15 @@ import Watching from "@/components/home/Watching.vue";
<template> <template>
<main class="center-content flex-col"> <main class="center-content flex-col">
<div class="a4page-portrait bdr-1 grid"> <div class="a4page-portrait bdr-1 grid">
<Intro class="intro bdr-2" /> <Intro class="intro bdr-primary bg-primary" />
<Listening class="listening bdr-2" /> <Listening class="listening bdr-primary bg-primary" />
<Stamps class="stamps bdr-2" /> <Stamps class="stamps bdr-primary bg-primary" />
<Feed class="feed bdr-2" /> <Feed class="feed bdr-primary bg-primary" />
<Links class="links bdr-2" /> <Links class="links bdr-primary bg-primary" />
<Collage class="collage bdr-2" /> <Collage class="collage bdr-primary bg-primary" />
<Favorites class="favorites bdr-2" /> <Favorites class="favorites bdr-primary bg-primary" />
<Gym class="gym bdr-2" /> <Gym class="gym bdr-primary bg-primary" />
<Watching class="watching bdr-2" /> <Watching class="watching bdr-primary bg-primary" />
</div> </div>
</main> </main>
</template> </template>