refactor: rename 'allow_change_password' to 'allow_modify_login_info' and update related logic across the application

This commit is contained in:
Junyan Qin
2025-12-29 21:14:05 +08:00
parent 863b26c3fa
commit f11e01b549
7 changed files with 24 additions and 11 deletions
@@ -23,8 +23,8 @@ class SystemRouterGroup(group.RouterGroup):
if 'cloud_service_url' in self.ap.instance_config.data.get('plugin', {}) if 'cloud_service_url' in self.ap.instance_config.data.get('plugin', {})
else 'https://space.langbot.app' else 'https://space.langbot.app'
), ),
'allow_change_password': self.ap.instance_config.data.get('system', {}).get( 'allow_modify_login_info': self.ap.instance_config.data.get('system', {}).get(
'allow_change_password', True 'allow_modify_login_info', True
), ),
} }
) )
@@ -73,9 +73,11 @@ class UserRouterGroup(group.RouterGroup):
@self.route('/change-password', methods=['POST'], auth_type=group.AuthType.USER_TOKEN) @self.route('/change-password', methods=['POST'], auth_type=group.AuthType.USER_TOKEN)
async def _(user_email: str) -> str: async def _(user_email: str) -> str:
# Check if password change is allowed # Check if password change is allowed
allow_change_password = self.ap.instance_config.data.get('system', {}).get('allow_change_password', True) allow_modify_login_info = self.ap.instance_config.data.get('system', {}).get(
if not allow_change_password: 'allow_modify_login_info', True
return self.http_status(403, -1, 'Password change is disabled') )
if not allow_modify_login_info:
return self.http_status(403, -1, 'Modifying login info is disabled')
json_data = await quart.request.json json_data = await quart.request.json
@@ -199,6 +201,13 @@ class UserRouterGroup(group.RouterGroup):
@self.route('/bind-space', methods=['POST'], auth_type=group.AuthType.NONE) @self.route('/bind-space', methods=['POST'], auth_type=group.AuthType.NONE)
async def _() -> str: async def _() -> str:
"""Bind Space account to existing local account""" """Bind Space account to existing local account"""
# Check if modifying login info is allowed
allow_modify_login_info = self.ap.instance_config.data.get('system', {}).get(
'allow_modify_login_info', True
)
if not allow_modify_login_info:
return self.http_status(403, -1, 'Modifying login info is disabled')
json_data = await quart.request.json json_data = await quart.request.json
code = json_data.get('code') code = json_data.get('code')
state = json_data.get('state') # JWT token passed as state state = json_data.get('state') # JWT token passed as state
+1 -1
View File
@@ -26,7 +26,7 @@ class UserService:
space_config = self.ap.instance_config.data.get('space', {}) space_config = self.ap.instance_config.data.get('space', {})
return { return {
'url': space_config.get('url', 'https://space.langbot.app'), 'url': space_config.get('url', 'https://space.langbot.app'),
'api_url': space_config.get('api_url', 'https://api.langbot.app'), 'models_gateway_api_url': space_config.get('models_gateway_api_url', 'https://api.langbot.cloud'),
'oauth_authorize_url': space_config.get('oauth_authorize_url', 'https://space.langbot.app/auth/authorize'), 'oauth_authorize_url': space_config.get('oauth_authorize_url', 'https://space.langbot.app/auth/authorize'),
} }
+2 -2
View File
@@ -16,7 +16,7 @@ proxy:
https: '' https: ''
system: system:
recovery_key: '' recovery_key: ''
allow_change_password: true allow_modify_login_info: true
jwt: jwt:
expire: 604800 expire: 604800
secret: '' secret: ''
@@ -75,6 +75,6 @@ space:
# Space service URL for OAuth and API # Space service URL for OAuth and API
url: 'https://space.langbot.app' url: 'https://space.langbot.app'
# Space API URL for model requests (MaaS) # Space API URL for model requests (MaaS)
api_url: 'https://api.langbot.app' models_gateway_api_url: 'https://api.langbot.cloud'
# OAuth authorization page URL (user will be redirected here) # OAuth authorization page URL (user will be redirected here)
oauth_authorize_url: 'https://space.langbot.app/auth/authorize' oauth_authorize_url: 'https://space.langbot.app/auth/authorize'
@@ -21,6 +21,7 @@ import {
ItemActions, ItemActions,
} from '@/components/ui/item'; } from '@/components/ui/item';
import { httpClient } from '@/app/infra/http/HttpClient'; import { httpClient } from '@/app/infra/http/HttpClient';
import { systemInfo } from '@/app/infra/http';
import { Loader2, ExternalLink, KeyRound } from 'lucide-react'; import { Loader2, ExternalLink, KeyRound } from 'lucide-react';
import PasswordChangeDialog from '../password-change-dialog/PasswordChangeDialog'; import PasswordChangeDialog from '../password-change-dialog/PasswordChangeDialog';
@@ -125,6 +126,7 @@ export default function AccountSettingsDialog({
variant="outline" variant="outline"
size="sm" size="sm"
onClick={() => setPasswordDialogOpen(true)} onClick={() => setPasswordDialogOpen(true)}
disabled={!systemInfo.allow_modify_login_info}
> >
{hasPassword {hasPassword
? t('common.changePassword') ? t('common.changePassword')
@@ -179,7 +181,9 @@ export default function AccountSettingsDialog({
variant="outline" variant="outline"
size="sm" size="sm"
onClick={handleBindSpace} onClick={handleBindSpace}
disabled={spaceBindLoading} disabled={
spaceBindLoading || !systemInfo.allow_modify_login_info
}
> >
{spaceBindLoading ? ( {spaceBindLoading ? (
<Loader2 className="mr-2 h-4 w-4 animate-spin" /> <Loader2 className="mr-2 h-4 w-4 animate-spin" />
+1 -1
View File
@@ -241,7 +241,7 @@ export interface ApiRespSystemInfo {
version: string; version: string;
cloud_service_url: string; cloud_service_url: string;
enable_marketplace: boolean; enable_marketplace: boolean;
allow_change_password: boolean; allow_modify_login_info: boolean;
} }
export interface ApiRespPluginSystemStatus { export interface ApiRespPluginSystemStatus {
+1 -1
View File
@@ -8,7 +8,7 @@ export let systemInfo: ApiRespSystemInfo = {
version: '', version: '',
enable_marketplace: true, enable_marketplace: true,
cloud_service_url: '', cloud_service_url: '',
allow_change_password: true, allow_modify_login_info: true,
}; };
/** /**