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