Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 38 additions & 29 deletions src/APIFunctions/Mailer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import axios from 'axios';
import { ApiResponse } from './ApiResponses';
import { BASE_API_URL } from '../Enums';

Expand All @@ -11,26 +10,27 @@ import { BASE_API_URL } from '../Enums';
*/
export async function sendVerificationEmail(email, token) {
let status = new ApiResponse();
const url = new URL('/api/Auth/sendVerificationEmail', BASE_API_URL);
await axios
.post(
url.href,
{
email
const url = new URL('/api/Auth/resendVerificationEmail', BASE_API_URL);
try {
const res = await fetch(url.href, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
{
headers: {
Authorization: `Bearer ${token}`
}
},
)
.then((response) => {
status.responseData = response;
})
.catch((error) => {
status.error = true;
status.responseData = error;
body: JSON.stringify({
email,
}),
});
if (res.ok) {
status.responseData = true;
} else {
status.error = true;
}
} catch(error) {
status.error = true;
status.responseData = error;
}
return status;
}

Expand All @@ -43,16 +43,25 @@ export async function sendVerificationEmail(email, token) {
export async function sendPasswordReset(email, captchaToken) {
let status = new ApiResponse();
const url = new URL('/api/Auth/sendPasswordReset', BASE_API_URL);
await axios
.post(url.href, {
email,
captchaToken,
})
.then((response) => {
status.responseData = response;
})
.catch((error) => {
status.error = error;
try {
const res = await fetch(url.href, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
email,
captchaToken,
}),
});
if (res.ok) {
const result = await res.json();
status.responseData = result;
} else {
status.error = true;
}
} catch(error) {
status.error = error;
}
return status;
}