Skip to content

Commit

Permalink
perf: sms env
Browse files Browse the repository at this point in the history
  • Loading branch information
xudaotutou committed Feb 27, 2025
1 parent c6f9542 commit 97eb08a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export default function Index(props: Omit<IconButtonProps, 'aria-label'>) {
}
/>
)}
{conf.authConfig?.idp.sms.enabled && conf.authConfig.idp.sms.email.enabled && (
{conf.authConfig?.idp.email.enabled && (
<ConfigItem
LeftElement={<Text>{t('common:email')}</Text>}
RightElement={
Expand Down
6 changes: 3 additions & 3 deletions frontend/desktop/src/pages/api/platform/getAuthConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ function genResAuthClientConfig(conf: AuthConfigType) {
enabled: !!conf.idp.sms?.enabled,
ali: {
enabled: !!conf.idp.sms?.ali?.enabled
},
email: {
enabled: !!conf.idp.sms?.email?.enabled
}
},
email: {
enabled: !!conf.idp.email?.enabled
},
github: {
enabled: !!conf.idp.github?.enabled,
proxyAddress: conf.idp.github?.proxyAddress || '',
Expand Down
4 changes: 2 additions & 2 deletions frontend/desktop/src/services/backend/sms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Captcha, * as $Captcha from '@alicloud/captcha20230305';
import nodemailer from 'nodemailer';
const getTransporter = () => {
if (!global.nodemailer) {
const emailConfig = global.AppConfig.desktop.auth.idp.sms?.email;
const emailConfig = global.AppConfig.desktop.auth.idp.email;
if (!emailConfig) throw Error('email transporter config error');
const transporter = nodemailer.createTransport({
pool: true,
Expand Down Expand Up @@ -118,7 +118,7 @@ export const captchaReq = async ({ captchaVerifyParam }: { captchaVerifyParam?:
}, 3);
};
export const emailSmsReq = async (email: string) => {
const emailConfig = global.AppConfig.desktop.auth.idp.sms?.email;
const emailConfig = global.AppConfig.desktop.auth.idp.email;
if (!emailConfig) throw Error('config error');

const code = Math.floor(Math.random() * 900000 + 100000).toString();
Expand Down
3 changes: 1 addition & 2 deletions frontend/desktop/src/services/enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export const enableGithub = () => global.AppConfig.desktop.auth.idp.github?.enab
export const enableSms = () => global.AppConfig.desktop.auth.idp.sms?.enabled || false;
export const enablePhoneSms = () =>
enableSms() && !!global.AppConfig.desktop.auth.idp.sms?.ali?.enabled;
export const enableEmailSms = () =>
enableSms() && !!global.AppConfig.desktop.auth.idp.sms?.email?.enabled;
export const enableEmailSms = () => !!global.AppConfig.desktop.auth.idp.email?.enabled;
export const enableWechat = () => global.AppConfig.desktop.auth.idp.wechat?.enabled || false;
export const enableGoogle = () => global.AppConfig.desktop.auth.idp.google?.enabled || false;
export const enableSignUp = () => global.AppConfig.desktop.auth.signUpEnabled || false;
Expand Down
52 changes: 26 additions & 26 deletions frontend/desktop/src/types/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ export type AuthConfigType = {
accessKeyID: string;
accessKeySecret?: string;
};
email?: {
enabled: boolean;
host: string;
port: number;
user: string;
password: string;
};
};
email?: {
enabled: boolean;
host: string;
port: number;
user: string;
password: string;
};
};
captcha?: {
Expand All @@ -154,7 +154,19 @@ export type AuthConfigType = {
};
};

export type AuthClientConfigType = DeepRequired<
export type AuthClientConfigType = {
idp: {
sms: {
enabled: boolean;
ali: {
enabled: boolean;
};
};
email: {
enabled: boolean;
};
};
} & DeepRequired<
OmitPathArr<
AuthConfigType,
[
Expand All @@ -166,8 +178,8 @@ export type AuthClientConfigType = DeepRequired<
'idp.github.clientSecret',
'idp.wechat.clientSecret',
'idp.google.clientSecret',
'idp.sms.ali',
'idp.sms.email',
'idp.sms',
'idp.email',
'idp.oauth2.clientSecret',
'jwt',
'billingUrl',
Expand All @@ -179,19 +191,7 @@ export type AuthClientConfigType = DeepRequired<
'captcha.ali.endpoint'
]
>
> & {
idp: {
sms: {
enabled: boolean;
ali: {
enabled: boolean;
};
email: {
enabled: boolean;
};
};
};
};
>;

export type JwtConfigType = {
internal?: string;
Expand Down Expand Up @@ -313,11 +313,11 @@ export const DefaultAuthClientConfig: AuthClientConfigType = {
enabled: false,
ali: {
enabled: false
},
email: {
enabled: false
}
},
email: {
enabled: false
},
oauth2: {
enabled: false,
callbackURL: '',
Expand Down

0 comments on commit 97eb08a

Please sign in to comment.