feat: hide login domain
This commit is contained in:
@@ -134,7 +134,7 @@ const en = {
|
||||
loginSwitch: 'Sign in',
|
||||
websiteSetting: 'Website',
|
||||
websiteReg: 'Sign Up',
|
||||
loginDomain: 'Sign-In Box Domain',
|
||||
loginDomain: 'Hide Sign-In Domain',
|
||||
multipleEmail: 'Multiple Email Address',
|
||||
multipleEmailDesc: 'Enable this feature to allow users to add multiple email',
|
||||
customization: 'Customization',
|
||||
|
||||
@@ -134,7 +134,7 @@ const zh = {
|
||||
loginSwitch: '去登录',
|
||||
websiteSetting: '网站设置',
|
||||
websiteReg: '用户注册',
|
||||
loginDomain: '登录框域名',
|
||||
loginDomain: '隐藏登录域名',
|
||||
multipleEmail: '多号模式',
|
||||
multipleEmailDesc: '开启后账号栏出现一个用户可以添加多个邮箱',
|
||||
customization: '个性化设置',
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
</template>
|
||||
<script setup>
|
||||
import {Icon} from "@iconify/vue";
|
||||
import {nextTick, reactive, ref, watch} from "vue";
|
||||
import {computed, nextTick, reactive, ref, watch} from "vue";
|
||||
import {
|
||||
accountList,
|
||||
accountAdd,
|
||||
@@ -153,7 +153,7 @@ const settingStore = useSettingStore();
|
||||
const emailStore = useEmailStore();
|
||||
const showAdd = ref(false)
|
||||
const addLoading = ref(false);
|
||||
const domainList = settingStore.domainList
|
||||
const domainList = computed(() => settingStore.domainList)
|
||||
const accounts = reactive([])
|
||||
const noLoading = ref(false)
|
||||
const loading = ref(false)
|
||||
@@ -189,6 +189,12 @@ watch(() => accountStore.changeUserAccountName, () => {
|
||||
accounts[0].name = accountStore.changeUserAccountName
|
||||
})
|
||||
|
||||
watch(() => settingStore.domainList, (list) => {
|
||||
if (!addForm.suffix && list.length > 0) {
|
||||
addForm.suffix = list[0]
|
||||
}
|
||||
}, {immediate: true})
|
||||
|
||||
|
||||
const openSelect = () => {
|
||||
mySelect.value.toggleMenu()
|
||||
@@ -338,6 +344,7 @@ function changeAccount(account) {
|
||||
}
|
||||
|
||||
function add() {
|
||||
addForm.suffix = addForm.suffix || settingStore.domainList[0]
|
||||
showAdd.value = true
|
||||
setTimeout(() => {
|
||||
addRef.value.focus()
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
<span class="form-desc" v-if="show === 'login'">{{ $t('loginTitle') }}</span>
|
||||
<span class="form-desc" v-else>{{ $t('regTitle') }}</span>
|
||||
<div v-show="show === 'login'">
|
||||
<el-input :class="settingStore.settings.loginDomain === 0 ? 'email-input' : ''" v-model="form.email"
|
||||
<el-input :class="!hideLoginDomain ? 'email-input' : ''" v-model="form.email"
|
||||
type="text" :placeholder="$t('emailAccount')" autocomplete="off">
|
||||
<template #append v-if="settingStore.settings.loginDomain === 0">
|
||||
<template #append v-if="!hideLoginDomain">
|
||||
<div @click.stop="openSelect">
|
||||
<el-select
|
||||
v-if="show === 'login'"
|
||||
@@ -49,9 +49,9 @@
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-show="show !== 'login'">
|
||||
<el-input class="email-input" v-model="registerForm.email" type="text" :placeholder="$t('emailAccount')"
|
||||
<el-input :class="!hideLoginDomain ? 'email-input' : ''" v-model="registerForm.email" type="text" :placeholder="$t('emailAccount')"
|
||||
autocomplete="off">
|
||||
<template #append>
|
||||
<template #append v-if="!hideLoginDomain">
|
||||
<div @click.stop="openSelect">
|
||||
<el-select
|
||||
v-if="show !== 'login'"
|
||||
@@ -108,8 +108,8 @@
|
||||
</div>
|
||||
<el-dialog class="bind-dialog" v-model="showBindForm" title="注册邮箱" >
|
||||
<div class="bind-container">
|
||||
<el-input v-model="bindForm.email" type="text" :placeholder="$t('emailAccount')" autocomplete="off">
|
||||
<template #append>
|
||||
<el-input :class="!hideLoginDomain ? 'email-input' : ''" v-model="bindForm.email" type="text" :placeholder="$t('emailAccount')" autocomplete="off">
|
||||
<template #append v-if="!hideLoginDomain">
|
||||
<div @click.stop="openSelect">
|
||||
<el-select
|
||||
ref="mySelect"
|
||||
@@ -151,6 +151,7 @@ import router from "@/router";
|
||||
import {computed, nextTick, reactive, ref} from "vue";
|
||||
import {login} from "@/request/login.js";
|
||||
import {register} from "@/request/login.js";
|
||||
import {websiteConfig} from "@/request/setting.js";
|
||||
import {isEmail} from "@/utils/verify-utils.js";
|
||||
import {useSettingStore} from "@/store/setting.js";
|
||||
import {useAccountStore} from "@/store/account.js";
|
||||
@@ -236,6 +237,8 @@ const loginOpacity = computed(() => {
|
||||
return uiStore.dark ? `rgba(0, 0, 0, ${opacity})` : `rgba(255, 255, 255, ${opacity})`
|
||||
})
|
||||
|
||||
const hideLoginDomain = computed(() => settingStore.settings.loginDomain === 1)
|
||||
|
||||
const background = computed(() => {
|
||||
|
||||
return settingStore.settings.background ? {
|
||||
@@ -250,6 +253,14 @@ const openSelect = () => {
|
||||
mySelect.value.toggleMenu()
|
||||
}
|
||||
|
||||
const getFullEmail = (email) => {
|
||||
return hideLoginDomain.value ? email : email + suffix.value
|
||||
}
|
||||
|
||||
const getEmailName = (email) => {
|
||||
return email.split('@')[0]
|
||||
}
|
||||
|
||||
function linuxDoLogin() {
|
||||
const clientId = settingStore.settings.linuxdoClientId
|
||||
const redirectUri = encodeURIComponent(settingStore.settings.linuxdoCallbackUrl)
|
||||
@@ -305,7 +316,7 @@ function bind() {
|
||||
}
|
||||
|
||||
|
||||
if (bindForm.email.length < settingStore.settings.minEmailPrefix) {
|
||||
if (getEmailName(bindForm.email).length < settingStore.settings.minEmailPrefix) {
|
||||
ElMessage({
|
||||
message: t('minEmailPrefix', {msg: settingStore.settings.minEmailPrefix}),
|
||||
type: 'error',
|
||||
@@ -314,7 +325,7 @@ function bind() {
|
||||
return
|
||||
}
|
||||
|
||||
let email = bindForm.email + suffix.value;
|
||||
let email = getFullEmail(bindForm.email);
|
||||
|
||||
|
||||
if (!isEmail(email)) {
|
||||
@@ -340,7 +351,7 @@ function bind() {
|
||||
|
||||
}
|
||||
|
||||
const form = {email: bindForm.email + suffix.value, oauthUserId: bindForm.oauthUserId, code: bindForm.code}
|
||||
const form = {email, oauthUserId: bindForm.oauthUserId, code: bindForm.code}
|
||||
|
||||
bindLoading.value = true
|
||||
oauthBindUser(form).then(data => {
|
||||
@@ -361,7 +372,7 @@ const submit = () => {
|
||||
return
|
||||
}
|
||||
|
||||
let email = form.email + (settingStore.settings.loginDomain === 0 ? suffix.value : '');
|
||||
let email = getFullEmail(form.email);
|
||||
|
||||
if (!isEmail(email)) {
|
||||
ElMessage({
|
||||
@@ -391,6 +402,7 @@ const submit = () => {
|
||||
|
||||
async function saveToken(token) {
|
||||
localStorage.setItem('token', token)
|
||||
refreshWebsiteConfig()
|
||||
const user = await loginUserInfo();
|
||||
accountStore.currentAccountId = user.account.accountId;
|
||||
accountStore.currentAccount = user.account;
|
||||
@@ -405,6 +417,19 @@ async function saveToken(token) {
|
||||
bindLoading.value = false;
|
||||
}
|
||||
|
||||
function refreshWebsiteConfig() {
|
||||
websiteConfig().then(setting => {
|
||||
settingStore.settings = setting
|
||||
settingStore.domainList = setting.domainList
|
||||
if (!suffix.value && setting.domainList.length > 0) {
|
||||
suffix.value = setting.domainList[0]
|
||||
}
|
||||
document.title = setting.title
|
||||
}).catch(e => {
|
||||
console.error(e)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function submitRegister() {
|
||||
|
||||
@@ -419,7 +444,7 @@ function submitRegister() {
|
||||
|
||||
console.log(registerForm.email)
|
||||
|
||||
if (registerForm.email.length < settingStore.settings.minEmailPrefix) {
|
||||
if (getEmailName(registerForm.email).length < settingStore.settings.minEmailPrefix) {
|
||||
ElMessage({
|
||||
message: t('minEmailPrefix', {msg: settingStore.settings.minEmailPrefix}),
|
||||
type: 'error',
|
||||
@@ -428,7 +453,9 @@ function submitRegister() {
|
||||
return
|
||||
}
|
||||
|
||||
if (!isEmail(registerForm.email + suffix.value)) {
|
||||
const email = getFullEmail(registerForm.email);
|
||||
|
||||
if (!isEmail(email)) {
|
||||
ElMessage({
|
||||
message: t('notEmailMsg'),
|
||||
type: 'error',
|
||||
@@ -507,7 +534,7 @@ function submitRegister() {
|
||||
registerLoading.value = true
|
||||
|
||||
const form = {
|
||||
email: registerForm.email + suffix.value,
|
||||
email,
|
||||
password: registerForm.password,
|
||||
token: verifyToken,
|
||||
code: registerForm.code
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<div class="setting-item">
|
||||
<div><span>{{ $t('loginDomain') }}</span></div>
|
||||
<div>
|
||||
<el-switch @change="change" :before-change="beforeChange" :active-value="0" :inactive-value="1"
|
||||
<el-switch @change="change" :before-change="beforeChange" :active-value="1" :inactive-value="0"
|
||||
v-model="setting.loginDomain"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import app from '../hono/hono';
|
||||
import result from '../model/result';
|
||||
import settingService from '../service/setting-service';
|
||||
import userContext from "../security/user-context";
|
||||
|
||||
app.put('/setting/set', async (c) => {
|
||||
await settingService.set(c, await c.req.json());
|
||||
|
||||
@@ -12,8 +12,8 @@ const userContext = {
|
||||
|
||||
async getToken(c) {
|
||||
const jwt = c.req.header(constant.TOKEN_HEADER);
|
||||
const { token } = JwtUtils.verifyToken(c,jwt);
|
||||
return token;
|
||||
const result = await JwtUtils.verifyToken(c,jwt);
|
||||
return result?.token;
|
||||
},
|
||||
};
|
||||
export default userContext;
|
||||
|
||||
@@ -259,7 +259,6 @@ const accountService = {
|
||||
|
||||
async setAsTop(c, params, userId) {
|
||||
const { accountId } = params;
|
||||
console.log(accountId);
|
||||
const userRow = await userService.selectById(c, userId);
|
||||
const mainAccountRow = await accountService.selectByEmailIncludeDel(c, userRow.email);
|
||||
let mainSort = mainAccountRow.sort === 0 ? 2 : mainAccountRow.sort + 1;
|
||||
|
||||
@@ -165,7 +165,6 @@ const roleService = {
|
||||
const availIndex = availDomain.findIndex(item => {
|
||||
const domain = emailUtils.getDomain(email.toLowerCase());
|
||||
const availDomainItem = item.toLowerCase();
|
||||
console.log(domain,availDomainItem)
|
||||
return domain === availDomainItem
|
||||
})
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import constant from '../const/constant';
|
||||
import BizError from '../error/biz-error';
|
||||
import {t} from '../i18n/i18n'
|
||||
import verifyRecordService from './verify-record-service';
|
||||
import userContext from '../security/user-context';
|
||||
|
||||
const settingService = {
|
||||
|
||||
@@ -59,8 +60,6 @@ const settingService = {
|
||||
linuxdoSwitch = false
|
||||
}
|
||||
|
||||
console.log(projectLink)
|
||||
|
||||
if (typeof projectLink === 'string' && projectLink === 'false') {
|
||||
projectLink = false
|
||||
} else if (projectLink === false) {
|
||||
@@ -195,6 +194,7 @@ const settingService = {
|
||||
async websiteConfig(c) {
|
||||
|
||||
const settingRow = await this.get(c, true);
|
||||
const token = await userContext.getToken(c);
|
||||
|
||||
return {
|
||||
register: settingRow.register,
|
||||
@@ -209,7 +209,7 @@ const settingService = {
|
||||
siteKey: settingRow.siteKey,
|
||||
background: settingRow.background,
|
||||
loginOpacity: settingRow.loginOpacity,
|
||||
domainList: settingRow.domainList,
|
||||
domainList: settingRow.loginDomain === 1 && !token ? [] : settingRow.domainList,
|
||||
regKey: settingRow.regKey,
|
||||
regVerifyOpen: settingRow.regVerifyOpen,
|
||||
addVerifyOpen: settingRow.addVerifyOpen,
|
||||
|
||||
Reference in New Issue
Block a user