-
My Account
+
+
Account
-
-
-
AVATAR
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Password (and eventually authenticator)
-
+
E-MAIL
+
+
+
-
Account Deletion
+
PASSWORD
+
+
+
ACCOUNT DELETION
@@ -44,22 +27,13 @@ if (!user) {
alert("could not fetch user info, aborting :(")
}
-let newPfpFile: File;
-
-const saveChanges = async () => {
+async function changeEmail() {
if (!user) return;
-
+
+
const formData = new FormData()
-
- if (newPfpFile) {
- formData.append("avatar", newPfpFile)
- }
-
const bytes = new TextEncoder().encode(JSON.stringify({
- display_name: user.display_name,
- username: user.username,
- pronouns: user.pronouns,
- about: user.about,
+ email: user.email,
}));
formData.append('json', new Blob([bytes], { type: 'application/json' }));
@@ -69,6 +43,14 @@ const saveChanges = async () => {
body: formData
})
+ const apiBase = useCookie("api_base").value;
+
+ if (apiBase) {
+ const stats = await useApi().fetchInstanceStats(apiBase);
+ if (stats.email_verification_required) {
+ return window.location.reload();
+ }
+ }
alert('success!!')
} catch (error: any) {
if (error?.response?.status !== 200) {
@@ -78,60 +60,24 @@ const saveChanges = async () => {
};
-const removeAvatar = async () => {
- alert("TBD")
- // await fetchWithApi(`/auth/reset-password`);
-}
-
-const changeAvatar = async () => {
- if (!user) return;
-
- const input = document.createElement('input');
- input.type = 'file';
- input.accept = 'image/*';
-
- input.addEventListener("change", (e: Event) => {
- if (input.files?.length && input.files.length > 0) {
- const file = input.files[0];
- if (!file) return;
-
- newPfpFile = file
-
- const reader = new FileReader();
- reader.addEventListener("onload", () => {
- if (reader.result && typeof reader.result === 'string') {
- user.avatar = reader.result;
- }
- });
- reader.readAsDataURL(file);
+async function resetPassword () {
+ await fetchWithApi("/auth/reset-password", {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ query: {
+ identifier: user?.username
}
- })
-
- input.click()
+ });
}
-const resetPassword = async () => {
- alert("TBD")
- // await fetchWithApi(`/auth/reset-password`);
-}
-
-const deleteAccount = async () => {
+async function deleteAccount() {
alert("TBD")
}
\ No newline at end of file
diff --git a/components/Settings/UserSettings/Profile.vue b/components/Settings/UserSettings/Profile.vue
new file mode 100644
index 0000000..04d1e30
--- /dev/null
+++ b/components/Settings/UserSettings/Profile.vue
@@ -0,0 +1,151 @@
+
+
+
Profile
+
+
+
+
AVATAR
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/UserArea.vue b/components/UserArea.vue
new file mode 100644
index 0000000..d922c3f
--- /dev/null
+++ b/components/UserArea.vue
@@ -0,0 +1,20 @@
+
+
+ HELLO!!
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/UserPopup.vue b/components/UserPopup.vue
index 092e7d5..a3a15cb 100644
--- a/components/UserPopup.vue
+++ b/components/UserPopup.vue
@@ -1,7 +1,9 @@
@@ -51,7 +28,6 @@
\ No newline at end of file
diff --git a/middleware/auth.global.ts b/middleware/auth.global.ts
index 2a9b752..c0da664 100644
--- a/middleware/auth.global.ts
+++ b/middleware/auth.global.ts
@@ -2,7 +2,21 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
console.log("to.fullPath:", to.fullPath);
const loading = useState("loading");
const accessToken = useCookie("access_token").value;
- if (["/login", "/register"].includes(to.path)) {
+ const apiBase = useCookie("api_base").value;
+ const { fetchInstanceStats } = useApi();
+
+ console.log("[AUTH] instance url:", apiBase);
+ if (apiBase && !Object.keys(to.query).includes("special") && to.path != "/verify-email") {
+ const user = await useAuth().getUser();
+ const stats = await fetchInstanceStats(apiBase);
+ console.log("[AUTH] stats:", stats);
+ console.log("[AUTH] email verification check:", user?.email && !user.email_verified && stats.email_verification_required);
+ if (user?.email && !user.email_verified && stats.email_verification_required) {
+ return await navigateTo("/register?special=verify_email");
+ }
+ }
+
+ if (["/login", "/register"].includes(to.path) && !Object.keys(to.query).includes("special")) {
console.log("path is login or register");
const apiBase = useCookie("api_base");
console.log("apiBase gotten:", apiBase.value);
@@ -19,6 +33,14 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
if (parsed.ApiBaseUrl) {
apiBase.value = `${parsed.ApiBaseUrl}/v${apiVersion}`;
console.log("set apiBase to:", parsed.ApiBaseUrl);
+ console.log("hHEYOO");
+ const instanceUrl = useCookie("instance_url");
+ console.log("hHEYOO 2");
+ console.log("instance url:", instanceUrl.value);
+ if (!instanceUrl.value) {
+ instanceUrl.value = `${requestUrl.protocol}//${requestUrl.host}`;
+ console.log("set instance url to:", instanceUrl.value);
+ }
}
}
}
diff --git a/nuxt.config.ts b/nuxt.config.ts
index 63d9372..46890d1 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -27,7 +27,12 @@ export default defineNuxtConfig({
runtimeConfig: {
public: {
apiVersion: 1,
- messageGroupingMaxDifference: 300000
+ messageGroupingMaxDifference: 300000,
+ buildTimeString: new Date().toISOString(),
+ gitHash: process.env.GIT_SHORT_REV || "N/A",
+ defaultThemes: [
+ "light", "ash", "dark", "rainbow-capitalism"
+ ]
}
},
/* nitro: {
diff --git a/package.json b/package.json
index b67a598..5d7d19e 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
"@nuxt/icon": "1.13.0",
"@nuxt/image": "1.10.0",
"@pinia/nuxt": "0.11.0",
+ "cropperjs": "^2.0.0",
"dompurify": "^3.2.6",
"marked": "^15.0.12",
"nuxt": "^3.17.0",
diff --git a/pages/index.vue b/pages/index.vue
index f970926..41deadf 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -1,6 +1,19 @@