feat(auth): remember password securely

This commit is contained in:
2026-08-20 23:41:33 +08:00
parent 1c6b004436
commit 990639f770
11 changed files with 530 additions and 17 deletions

View File

@@ -80,11 +80,16 @@ describe('auth store', () => {
await useAuthStore.getState().loginWithPassword({
username: 'zhangsan',
password: 'secret',
rememberPassword: true,
});
expect(hostApiFetchMock).toHaveBeenNthCalledWith(1, '/api/auth/login', {
method: 'POST',
body: JSON.stringify({ username: 'zhangsan', password: 'secret' }),
body: JSON.stringify({
username: 'zhangsan',
password: 'secret',
rememberPassword: true,
}),
});
expect(hostApiFetchMock).toHaveBeenNthCalledWith(2, '/api/auth/me');
expect(hostApiFetchMock).not.toHaveBeenCalledWith(
@@ -114,6 +119,7 @@ describe('auth store', () => {
expect(window.localStorage.getItem('niancode-auth')).not.toContain(
'must-not-return-to-renderer-storage',
);
expect(window.localStorage.getItem('niancode-auth')).not.toContain('secret');
});
it('logs in with a mobile code using only the phone and code payload', async () => {