Skip to content

Commit

Permalink
Merge pull request #1525 from hngx-org/bug-fixes
Browse files Browse the repository at this point in the history
updated auth endpoint to match latest changes
  • Loading branch information
Homoakin619 authored Dec 12, 2023
2 parents f95947f + 39709a6 commit 02ebc33
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions http/auth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import axios from 'axios';

const AUTH_HTTP_URL = 'https://zuri-auth.up.railway.app/api/auth/api/auth';
const AUTH_HTTP_URL_2 = 'https://staging.zuri.team/api/auth/api';
const _AUTH_HTTP_URL = 'https://zuri-auth.up.railway.app/api/auth/api';
const AUTH_HTTP_URL = 'https://zuri-auth.up.railway.app/api/v1';

const $http = axios.create({
baseURL: AUTH_HTTP_URL,
Expand All @@ -11,17 +9,10 @@ const $http = axios.create({
},
});

const $http_2 = axios.create({
baseURL: _AUTH_HTTP_URL,
timeout: 30000,
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
});

export const verfiy2FA = async (props: { token: string; code: string }) => {
try {
const res = await $http.post('/2fa/verify-code', props);
const res = await $http.post('/auth/2fa/verify-code', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -30,7 +21,7 @@ export const verfiy2FA = async (props: { token: string; code: string }) => {

export const resend2FACode = async (props: { email: string }) => {
try {
const res = await $http.post('/2fa/send-code', props);
const res = await $http.post('/auth/2fa/send-code', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -39,7 +30,7 @@ export const resend2FACode = async (props: { email: string }) => {

export const enabled2FA = async (props: { token: string }) => {
try {
const res = await $http.post('/2fa/enable', props);
const res = await $http.post('/auth/2fa/enable', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -48,7 +39,7 @@ export const enabled2FA = async (props: { token: string }) => {

export const disable2FA = async (props: { token: string }) => {
try {
const res = await $http.post('/2fa/disable', props);
const res = await $http.post('/auth/2fa/disable', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -57,7 +48,7 @@ export const disable2FA = async (props: { token: string }) => {

export const resetPassword = async (props: { token: string | string[] | undefined; password: string }) => {
try {
const response = await $http.patch('/reset-password', props);
const response = await $http.patch('/auth/reset-password', props);
return response?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -66,7 +57,7 @@ export const resetPassword = async (props: { token: string | string[] | undefine

export const signUpUser = async (props: { firstName: string; lastName: string; email: string; password: string }) => {
try {
const res = await $http.post('/signup', props);
const res = await $http.post('/auth/signup', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -75,7 +66,7 @@ export const signUpUser = async (props: { firstName: string; lastName: string; e

export const loginUser = async (props: { email: string; password: string }) => {
try {
const res = await $http.post('/login', props);
const res = await $http.post('/auth/login', props);
console.log('Login response', res);
return res?.data;
} catch (e: any) {
Expand All @@ -86,7 +77,7 @@ export const loginUser = async (props: { email: string; password: string }) => {

export const signUpUserWithEmail = async (props: { email: string }) => {
try {
const res = await $http.post('/check-email', props);
const res = await $http.post('/auth/check-email', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -95,7 +86,7 @@ export const signUpUserWithEmail = async (props: { email: string }) => {

export const checkEmail = async (props: { email: string }) => {
try {
const res = await $http.post('/check-email', props);
const res = await $http.post('/auth/check-email', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -104,7 +95,7 @@ export const checkEmail = async (props: { email: string }) => {

export const verifyUser = async (props: { token: string }) => {
try {
const res = await $http.get(`/verify/${props.token}`);
const res = await $http.get(`/auth/verify/${props.token}`);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -113,7 +104,7 @@ export const verifyUser = async (props: { token: string }) => {

export const resendVerification = async (props: { email: string }) => {
try {
const res = await $http.post('/verify/resend', props);
const res = await $http.post('/auth/verify/resend', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -122,7 +113,7 @@ export const resendVerification = async (props: { email: string }) => {

export const guestSignup = async (props: { email: string; firstName: string; lastName: string; password: string }) => {
try {
const res = await $http.post('/signup', props);
const res = await $http.post('/auth/signup', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -131,7 +122,7 @@ export const guestSignup = async (props: { email: string; firstName: string; las

export const forgetPassword = async (props: { email: string }) => {
try {
const res = await $http.post('/reset-password', props);
const res = await $http.post('/auth/reset-password', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -140,7 +131,7 @@ export const forgetPassword = async (props: { email: string }) => {

export const resendForgetPassword = async (props: { email: string }) => {
try {
const res = await $http.post('/reset-password', props);
const res = await $http.post('/auth/reset-password', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -149,7 +140,7 @@ export const resendForgetPassword = async (props: { email: string }) => {

export const revalidateAuth = async (props: { token: string }) => {
try {
const res = await $http.get(`/revalidate-login/${props.token}`);
const res = await $http.get(`/auth/revalidate-login/${props.token}`);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -158,7 +149,7 @@ export const revalidateAuth = async (props: { token: string }) => {

export const signUpWithOAuth = async (props: { query: string; oAuth: string }) => {
try {
const res = await $http.get(`/${props.oAuth}/redirect?${props.query}`);
const res = await $http.get(`/auth/${props.oAuth}/redirect?${props.query}`);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
Expand All @@ -167,13 +158,13 @@ export const signUpWithOAuth = async (props: { query: string; oAuth: string }) =

export const authorizeToken = async (props: { token: string }) => {
try {
const res = await $http_2.post('/authorize', props);
const res = await $http.post('/authorize', props);
return res?.data;
} catch (e: any) {
throw e?.response?.data || { message: e.message };
}
};

export const Google = () => {
return $http.get('/google');
return $http.get('/auth/google');
};

1 comment on commit 02ebc33

@vercel
Copy link

@vercel vercel bot commented on 02ebc33 Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

zuriportfolio-frontend – ./

zuriportfolio.vercel.app
zuriportfolio-frontend-zuri-team.vercel.app
zuriportfolio-frontend-git-dev-zuri-team.vercel.app

Please sign in to comment.