Email SMTP Fix
This commit is contained in:
@@ -71,8 +71,73 @@ export const AuthProvider = ({ children }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const forgotPassword = async (email) => {
|
||||
const response = await axios.post(`${API_URL}/api/auth/forgot-password`, { email });
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const resetPassword = async (token, newPassword) => {
|
||||
const response = await axios.post(`${API_URL}/api/auth/reset-password`, {
|
||||
token,
|
||||
new_password: newPassword
|
||||
});
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const changePassword = async (currentPassword, newPassword) => {
|
||||
const currentToken = localStorage.getItem('token');
|
||||
if (!currentToken) {
|
||||
throw new Error('Not authenticated');
|
||||
}
|
||||
|
||||
const response = await axios.put(
|
||||
`${API_URL}/api/users/change-password`,
|
||||
{
|
||||
current_password: currentPassword,
|
||||
new_password: newPassword
|
||||
},
|
||||
{
|
||||
headers: { Authorization: `Bearer ${currentToken}` }
|
||||
}
|
||||
);
|
||||
|
||||
// Refresh user data to clear force_password_change flag if it was set
|
||||
await refreshUser();
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const resendVerificationEmail = async () => {
|
||||
const currentToken = localStorage.getItem('token');
|
||||
if (!currentToken) {
|
||||
throw new Error('Not authenticated');
|
||||
}
|
||||
|
||||
const response = await axios.post(
|
||||
`${API_URL}/api/auth/resend-verification-email`,
|
||||
{},
|
||||
{
|
||||
headers: { Authorization: `Bearer ${currentToken}` }
|
||||
}
|
||||
);
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
return (
|
||||
<AuthContext.Provider value={{ user, token, login, logout, register, refreshUser, loading }}>
|
||||
<AuthContext.Provider value={{
|
||||
user,
|
||||
token,
|
||||
login,
|
||||
logout,
|
||||
register,
|
||||
refreshUser,
|
||||
forgotPassword,
|
||||
resetPassword,
|
||||
changePassword,
|
||||
resendVerificationEmail,
|
||||
loading
|
||||
}}>
|
||||
{children}
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user