Repository navigation
feat(account): 增加修改密码入口 #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a49ac5c
feat(account): add change password entry
065d24d
fix(account): configure password page through auth settings
73efe92
fix(frontend): narrow grpc collection lengths
536b0b3
fix(frontend): repair existing test type contracts
3e423c2
fix(test): align baseline mocks with runtime behavior
8544e8b
chore(account): remove unrelated review changes
82ce5f3
fix(account): configure packaged password links
69ae6fd
fix(desktop): document external browser result contract
4f166ee
fix(packaging): use formal links for public Windows packages
33af54f
fix(packaging): clarify public Windows account override
2e7b306
test(account): cover packaged URL defaults and Electron validation
9825f9a
docs(account): explain community password URL modes
e9c9bd5
docs(account): document account service alignment
be6d7bf
docs(account): document password URL precedence
712a013
test(packaging): cover invalid password URLs
cabb855
fix(account): require HTTPS password pages
998561d
docs(account): clarify disabled URL fallback
5c6b8cd
refactor(account): centralize desktop password page configuration
b53902c
docs(account): quote password page fragments in local environments
f1f9aae
test(account): pass subprocess fixtures as arguments
178d6c4
fix(account): separate cloud and local account menus
b868b5b
fix(account): tighten menu divider spacing
d41e91e
fix(account): match Figma menu divider color
00c04eb
Merge origin/main into feature/48-change-password
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| const DEFAULT_CHANGE_PASSWORD_URL = 'https://www.opentest.com/account/#change-password' | ||
|
|
||
| // Account pages are independent of the native license mode. This is the only | ||
| // developer override; packaged applications consume the generated desktop settings. | ||
| function resolveChangePasswordUrl(env = process.env) { | ||
| const value = env.CASDOOR_CHANGE_PASSWORD_URL | ||
| if (value === undefined || (typeof value === 'string' && !value.trim())) return DEFAULT_CHANGE_PASSWORD_URL | ||
| try { | ||
| const url = new URL(value) | ||
| if (url.protocol !== 'https:' || url.username || url.password) throw new Error('invalid URL') | ||
| return url.href | ||
| } catch { | ||
| throw new Error('CASDOOR_CHANGE_PASSWORD_URL 必须是无凭据的 HTTPS URL') | ||
| } | ||
| } | ||
|
|
||
| module.exports = { DEFAULT_CHANGE_PASSWORD_URL, resolveChangePasswordUrl } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { expect, it, vi } from 'vitest' | ||
| import { readFileSync } from 'node:fs' | ||
| import { createRequire } from 'node:module' | ||
| import { runInNewContext } from 'node:vm' | ||
|
|
||
| const require = createRequire(import.meta.url) | ||
| const frontendUrl = 'http://127.0.0.1:19010' | ||
| const event = { senderFrame: { url: `${frontendUrl}/home` } } | ||
|
|
||
| function load(file, mocks) { | ||
| const module = { exports: {} } | ||
| runInNewContext(readFileSync(new URL(`../../src/${file}`, import.meta.url), 'utf8'), { | ||
| module, exports: module.exports, require: id => { | ||
| if (!Object.hasOwn(mocks, id)) throw new Error(`Unexpected dependency in ${file}: ${id}`) | ||
|
KyleHuangFromHZ marked this conversation as resolved.
Resolved
KyleHuangFromHZ marked this conversation as resolved.
Resolved
|
||
| return mocks[id] | ||
| }, | ||
| __dirname: 'desktop/src', process, console: { ...console, error() {} } | ||
| }) | ||
| return module.exports | ||
| } | ||
|
|
||
| function environment() { | ||
| const handlers = new Map() | ||
| const ipcMain = { handle: (name, handler) => handlers.set(name, handler), on: () => {} } | ||
| const shell = { openExternal: vi.fn().mockResolvedValue(undefined) } | ||
| const noop = () => {} | ||
| const register = load('ipcMainHandler.js', { | ||
|
KyleHuangFromHZ marked this conversation as resolved.
Resolved
KyleHuangFromHZ marked this conversation as resolved.
Resolved
KyleHuangFromHZ marked this conversation as resolved.
Resolved
KyleHuangFromHZ marked this conversation as resolved.
Resolved
|
||
| electron: { ipcMain, shell }, https: {}, fs: {}, path: require('node:path'), | ||
| './logger': { warn: vi.fn() }, './utils/launch-info': {}, './utils': {}, | ||
| './config/index': { APP_CONFIG: { dev: {} }, IS_DEV_MODE: false, IS_PRODUCTION: true, VERSION: 'test' }, | ||
| './page-zoom': { registerPageZoomIpcHandlers: noop }, './window/native-close': { registerNativeWindowCloseIpcHandlers: noop }, | ||
| './analytics/ipc-handlers': { registerAnalyticsIpcHandlers: noop }, | ||
| './feedback/ipc-handlers': { registerFeedbackIpcHandlers: noop }, | ||
| './report-pdf-export': { registerReportPdfExportHandler: noop }, './app-update': { registerAppUpdateHandler: noop }, | ||
| './config/service': { serviceConfig: { frontendUrl } }, './config/project-paths': {}, | ||
| './config/public-auth': { getPublicAuthConfig: () => ({}) }, './config/updates': { getProductUpdateConfig: () => ({}) }, | ||
| './policies/window-navigation-policy': require('../../src/policies/window-navigation-policy'), | ||
| './utils/window': {}, './detached-card/window-manager': { createDetachedCardWindowManager: () => ({}) }, | ||
| './detached-card/ipc-handlers': { registerDetachedCardIpcHandlers: noop }, './service/backend': {}, | ||
| './grpc/dialog-interaction-client': {}, | ||
| './sequence-dialog/session-manager': { createSequenceDialogSessionManager: () => ({}) }, | ||
| './utils/storage': {}, './service/auth': {} | ||
| }) | ||
| register({ webContents: { id: 1, on: noop }, on: noop }) | ||
| const bridge = {} | ||
| load('preload.js', { | ||
| electron: { | ||
| contextBridge: { exposeInMainWorld: (name, api) => { bridge[name] = api } }, | ||
| webUtils: { getPathForFile: () => '' }, | ||
| ipcRenderer: { invoke: (channel, ...args) => handlers.get(channel)(event, ...args) } | ||
| }, | ||
| './feedback/fingerprint': { createFeedbackFingerprint: () => ({}) }, | ||
| '../../../cli/bridge/preload.cjs': { createAutomationPreload: () => ({}) } | ||
| }) | ||
| return { api: bridge.electronAPI, handlers, shell } | ||
| } | ||
|
|
||
| it('returns the successful external browser result through the preload bridge', async () => { | ||
| const environmentState = environment() | ||
| const url = 'https://test-account.example/account/#change-password' | ||
|
|
||
| await expect(environmentState.api.openExternalBrowser(url)).resolves.toEqual({ success: true }) | ||
| expect(environmentState.shell.openExternal).toHaveBeenCalledExactlyOnceWith(url) | ||
| }) | ||
|
|
||
| it('returns a failure result when the external browser rejects or the URL is invalid', async () => { | ||
| const environmentState = environment() | ||
| environmentState.shell.openExternal.mockRejectedValueOnce(new Error('browser unavailable')) | ||
|
|
||
| await expect(environmentState.api.openExternalBrowser('https://test-account.example/account/#change-password')) | ||
| .resolves.toMatchObject({ success: false }) | ||
| await expect(environmentState.api.openExternalBrowser('javascript:alert(1)')) | ||
| .resolves.toMatchObject({ success: false }) | ||
| expect(environmentState.shell.openExternal).toHaveBeenCalledOnce() | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.