Skip to content

Commit 811603b

Browse files
committed
Fix the wallet running during login and register
1 parent 4a9949b commit 811603b

2 files changed

Lines changed: 3 additions & 23 deletions

File tree

frontend/src/pages/Login.jsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useState } from 'react';
22
import { Box, Paper, TextField, Button, Typography } from '@mui/material';
33
import { login } from '../api/auth';
44
import { API_BASE } from '../config/apiConfig';
5-
import { walletLogin, getWalletPublicKey } from '../wallet/resvault';
65
import { Link, useNavigate } from 'react-router-dom';
76
import { formatErrorMessage, clientValidation } from '../utils/errorHandling';
87

@@ -20,22 +19,6 @@ export default function Login({ onAuthed }) {
2019

2120
console.log('Login attempt:', { username: u, password: p.length > 0 ? '***' : 'empty' });
2221

23-
let walletPubKey = null;
24-
try {
25-
console.log('Attempting wallet login...');
26-
// Set a timeout for wallet operations to prevent hanging
27-
await Promise.race([
28-
(async () => {
29-
await walletLogin();
30-
walletPubKey = await getWalletPublicKey();
31-
console.log('Wallet login successful:', walletPubKey);
32-
})(),
33-
new Promise((_, reject) => setTimeout(() => reject(new Error('Wallet timeout')), 3000))
34-
]);
35-
} catch (err) {
36-
console.warn('Wallet login failed or timed out (optional):', err.message);
37-
}
38-
3922
// Client-side validation to provide immediate feedback
4023
const usernameTrim = (u || '').trim();
4124
const usernameError = clientValidation.username(usernameTrim);
@@ -55,9 +38,9 @@ export default function Login({ onAuthed }) {
5538
try {
5639
console.log('Attempting API login...');
5740
console.log('Making fetch request to:', `${API_BASE}/auth/login`);
58-
console.log('Request body:', { username: usernameTrim, password: '***', walletPubKey });
41+
console.log('Request body:', { username: usernameTrim, password: '***' });
5942

60-
const res = await login(usernameTrim, p, walletPubKey);
43+
const res = await login(usernameTrim, p, null);
6144
console.log('API login successful:', res);
6245
onAuthed({ token: res.token, user: res.user });
6346
nav('/dashboard');

frontend/src/pages/Register.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useState } from 'react';
22
import { Box, Paper, TextField, Button, Typography } from '@mui/material';
33
import { register } from '../api/auth';
4-
import { walletLogin, getWalletPublicKey } from '../wallet/resvault';
54
import { Link, useNavigate } from 'react-router-dom';
65
import { formatErrorMessage, clientValidation } from '../utils/errorHandling';
76

@@ -16,7 +15,6 @@ export default function Register({ onAuthed }) {
1615
e.preventDefault();
1716
setError(null);
1817
setLoading(true);
19-
let walletPubKey = null;
2018
try {
2119
const usernameTrim = (u || '').trim();
2220
const usernameError = clientValidation.username(usernameTrim);
@@ -33,8 +31,7 @@ export default function Register({ onAuthed }) {
3331
return;
3432
}
3533

36-
try { await walletLogin(); walletPubKey = await getWalletPublicKey(); } catch (_) { /* ignore wallet failures */ }
37-
const res = await register(usernameTrim, p, walletPubKey);
34+
const res = await register(usernameTrim, p, null);
3835
onAuthed({ token: res.token, user: res.user });
3936
nav('/dashboard');
4037
} catch (err) {

0 commit comments

Comments
 (0)