@ -62,7 +62,7 @@
font-weight: bold;
font-weight: bold;
overflow: hidden;
overflow: hidden;
}
}
.avatar img {
.avatar img {
width: 100%;
width: 100%;
height: 100%;
height: 100%;
@ -156,7 +156,8 @@
< div class = "avatar-wrapper" @ click = "triggerAvatarUpload" >
< div class = "avatar-wrapper" @ click = "triggerAvatarUpload" >
< div class = "avatar" >
< div class = "avatar" >
< img v-if = "user.avatar" :src = "user.avatar" alt = "Avatar" >
< img v-if = "user.avatar" :src = "user.avatar" alt = "Avatar" >
< span v-else > {{ user.nickname ? user.nickname.charAt(0).toUpperCase() : (user.username ? user.username.charAt(0).toUpperCase() : 'U') }}< / span >
< span v-else > {{ user.nickname ? user.nickname.charAt(0).toUpperCase() : (user.username ?
user.username.charAt(0).toUpperCase() : 'U') }}< / span >
< / div >
< / div >
< div class = "avatar-overlay" >
< div class = "avatar-overlay" >
< i class = "fas fa-edit" > < / i >
< i class = "fas fa-edit" > < / i >
@ -167,7 +168,7 @@
< div style = "color: var(--color-text-light); font-size: 0.9rem;" > {{ $t('common.id') }}: {{ user.id }}< / div >
< div style = "color: var(--color-text-light); font-size: 0.9rem;" > {{ $t('common.id') }}: {{ user.id }}< / div >
< / div >
< / div >
< / div >
< / div >
< form style = "margin-top: var(--spacing-lg);" @ submit . prevent = "updateProfile" >
< form style = "margin-top: var(--spacing-lg);" @ submit . prevent = "updateProfile" >
< div class = "form-grid" >
< div class = "form-grid" >
< v-input label = "Username" :label = "$t('user.username')" v:value = "user.username" disabled > < / v-input >
< v-input label = "Username" :label = "$t('user.username')" v:value = "user.username" disabled > < / v-input >
@ -189,11 +190,14 @@
< div class = "section-title" > {{ $t('auth.security') || 'Security' }}< / div >
< div class = "section-title" > {{ $t('auth.security') || 'Security' }}< / div >
< form @ submit . prevent = "changePassword" >
< form @ submit . prevent = "changePassword" >
< div class = "form-grid" >
< div class = "form-grid" >
< v-input class = "form-full" :label = "$t('auth.old_password')" type = "password" v:value = "passwordForm.old_password" > < / v-input >
< v-input class = "form-full" :label = "$t('auth.old_password')" type = "password"
< v-input class = "form-full" :label = "$t('auth.new_password')" type = "password" v:value = "passwordForm.new_password" > < / v-input >
v:value="passwordForm.old_password">< / v-input >
< v-input class = "form-full" :label = "$t('auth.new_password')" type = "password"
v:value="passwordForm.new_password">< / v-input >
< / div >
< / div >
< div style = "margin-top: var(--spacing-md); display: flex; justify-content: flex-end;" >
< div style = "margin-top: var(--spacing-md); display: flex; justify-content: flex-end;" >
< v-btn type = "submit" variant = "outline" :loading = "pwdLoading" :disabled = "!passwordForm.new_password || !passwordForm.old_password" >
< v-btn type = "submit" variant = "outline" :loading = "pwdLoading"
:disabled="!passwordForm.new_password || !passwordForm.old_password">
{{ $t('auth.change_password') || 'Update Password' }}
{{ $t('auth.change_password') || 'Update Password' }}
< / v-btn >
< / v-btn >
< / div >
< / div >
@ -220,7 +224,8 @@
< / div >
< / div >
< / div >
< / div >
< div >
< div >
< v-btn v-if = "isBound(provider.code)" size = "sm" variant = "outline" color = "danger" :click = "() => unbind(provider.code)" >
< v-btn v-if = "isBound(provider.code)" size = "sm" variant = "outline" color = "danger"
:click="() => unbind(provider.code)">
{{ $t('common.unbind') }}
{{ $t('common.unbind') }}
< / v-btn >
< / v-btn >
< v-btn v-else size = "sm" variant = "outline" :click = "() => bind(provider.code)" >
< v-btn v-else size = "sm" variant = "outline" :click = "() => bind(provider.code)" >
@ -234,11 +239,11 @@
< / div >
< / div >
< / body >
< / body >
< script setup >
< script setup >
user = $env .$vbase.user || {};
user = $mod .$vbase.user || {};
loading = false;
loading = false;
pwdLoading = false;
pwdLoading = false;
passwordForm = { old_password: '', new_password: '' };
passwordForm = {old_password: '', new_password: ''};
// Bindings
// Bindings
providers = [];
providers = [];
bindings = [];
bindings = [];
@ -246,7 +251,7 @@
// Fetch fresh data
// Fetch fresh data
loadUser = async () => {
loadUser = async () => {
try {
try {
user = await $env .$vbase.fetchUser();
user = await $mod .$vbase.fetchUser();
} catch (e) {
} catch (e) {
console.error(e);
console.error(e);
}
}
@ -260,7 +265,7 @@
code: p.type,
code: p.type,
name: p.name
name: p.name
}));
}));
// Get current bindings
// Get current bindings
bindings = await $axios.get('/api/auth/me/bindings');
bindings = await $axios.get('/api/auth/me/bindings');
} catch (e) {
} catch (e) {
@ -305,19 +310,19 @@
};
};
handleLogout = async () => {
handleLogout = async () => {
await $env .$vbase.logout('/login');
await $mod .$vbase.logout('/login');
};
};
// OAuth Helpers
// OAuth Helpers
isBound = (code) => {
isBound = (code) => {
return bindings.some(b => b.provider === code);
return bindings.some(b => b.provider === code);
};
};
getBindInfo = (code) => {
getBindInfo = (code) => {
const b = bindings.find(b => b.provider === code);
const b = bindings.find(b => b.provider === code);
return b ? (b.provider_name || b.email || $t('auth.linked')) : '';
return b ? (b.provider_name || b.email || $t('auth.linked')) : '';
};
};
bind = async (provider) => {
bind = async (provider) => {
try {
try {
// Fetch authorization URL
// Fetch authorization URL
@ -336,7 +341,7 @@
$message.error(e.message);
$message.error(e.message);
}
}
};
};
unbind = async (provider) => {
unbind = async (provider) => {
try {
try {
await $message.confirm($t('auth.unbind_confirm'));
await $message.confirm($t('auth.unbind_confirm'));
@ -347,7 +352,7 @@
if (e !== 'cancel') $message.error(e.message);
if (e !== 'cancel') $message.error(e.message);
}
}
};
};
triggerAvatarUpload = async () => {
triggerAvatarUpload = async () => {
try {
try {
const url = await $message.prompt($t('user.avatar_url'), user.avatar || '');
const url = await $message.prompt($t('user.avatar_url'), user.avatar || '');
@ -365,4 +370,4 @@
$data.loadBindings();
$data.loadBindings();
< / script >
< / script >
< / html >
< / html >