@xouteiro/auth_npm 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -56,7 +56,7 @@ const messageStyle = (success) => ({
|
|
56
56
|
fontSize: 15,
|
57
57
|
});
|
58
58
|
|
59
|
-
export default function LoginRegisterFlow() {
|
59
|
+
export default function LoginRegisterFlow({ onLoginSuccess, onRegisterSuccess }) {
|
60
60
|
const [mode, setMode] = useState('login');
|
61
61
|
const [identifier, setIdentifier] = useState('');
|
62
62
|
const [password, setPassword] = useState('');
|
@@ -78,13 +78,14 @@ export default function LoginRegisterFlow() {
|
|
78
78
|
e.preventDefault();
|
79
79
|
setMessage(null);
|
80
80
|
setSuccess(false);
|
81
|
-
const { error } = await signInWithEmail(identifier, password);
|
81
|
+
const { session, error } = await signInWithEmail(identifier, password);
|
82
82
|
if (error) {
|
83
83
|
setMessage(error.message || 'Login failed');
|
84
84
|
setSuccess(false);
|
85
85
|
} else {
|
86
86
|
setMessage('Login successful!');
|
87
87
|
setSuccess(true);
|
88
|
+
if (onLoginSuccess) onLoginSuccess(session);
|
88
89
|
setTimeout(resetFields, 1200);
|
89
90
|
}
|
90
91
|
};
|
@@ -93,13 +94,14 @@ export default function LoginRegisterFlow() {
|
|
93
94
|
e.preventDefault();
|
94
95
|
setMessage(null);
|
95
96
|
setSuccess(false);
|
96
|
-
const { error } = await registerWithEmail(identifier, password, username, phone);
|
97
|
+
const { user, error } = await registerWithEmail(identifier, password, username, phone);
|
97
98
|
if (error) {
|
98
99
|
setMessage(error.message || 'Registration failed');
|
99
100
|
setSuccess(false);
|
100
101
|
} else {
|
101
102
|
setMessage('Registration successful! Please check your email to confirm.');
|
102
103
|
setSuccess(true);
|
104
|
+
if (onRegisterSuccess) onRegisterSuccess(user);
|
103
105
|
setTimeout(resetFields, 2000);
|
104
106
|
}
|
105
107
|
};
|