Skip to content

Commit

Permalink
Merge branch 'development_2.0.0' into AddAuthPages
Browse files Browse the repository at this point in the history
  • Loading branch information
nabilasherif committed Aug 28, 2024
2 parents 705a3d8 + 7c8fb0a commit 1cf18f3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
1 change: 1 addition & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<script src="/config.js"></script>
</body>

</html>
9 changes: 9 additions & 0 deletions client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export {}

declare global {
interface Window {
env: {
SERVER_DOMAIN_NAME_API: string;
};
}
}
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@mdi/font": "7.4.47",
"axios": "^1.7.2",
"axios": "^1.7.5",
"core-js": "^3.37.1",
"md5": "^2.3.0",
"passport-github2": "^0.1.12",
Expand Down
10 changes: 5 additions & 5 deletions client/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 11 additions & 15 deletions client/src/api/axios.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import axios, { AxiosInstance } from 'axios'
import axiosClient from 'axios'
import md5 from 'md5'
const AuthClient: AxiosInstance = axios.create({
baseURL: 'https://server.gent02.dev.grid.tf/api',

const accessToken = localStorage.getItem('TESTTRACKER_ACCESS_TOKEN')
export const axios = axiosClient.create({
baseURL: window.env.SERVER_DOMAIN_NAME_API,
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + localStorage.getItem('TEST_TRACKER_ACCESS_TOKEN'),
Authorization: `Bearer ${accessToken}`,
},
})

const BaseClient: AxiosInstance = axios.create({
baseURL: 'https://server.gent02.dev.grid.tf/api',
})

async function SignUp (newUser:any) {
try {
await BaseClient.post('/auth/signup/', newUser)
await axios.post('/auth/signup/', newUser)
} catch (error) {
console.error(error)
throw error
Expand All @@ -23,7 +19,7 @@ async function SignUp (newUser:any) {

async function SignUpInvitation (passwords:any) {
try {
await BaseClient.put('/members/set_password/', passwords)
await axios.put('/members/set_password/', passwords)
} catch (error) {
console.error(error)
throw error
Expand All @@ -32,7 +28,7 @@ async function SignUpInvitation (passwords:any) {

async function LogInUser (userInfo:any) {
try {
const response = await BaseClient.post('/auth/login/', userInfo)
const response = await axios.post('/auth/login/', userInfo)
const token = response.data.access_token
const refreshtoken = response.data.refresh_token
localStorage.setItem('TEST_TRACKER_ACCESS_TOKEN', token)
Expand All @@ -46,11 +42,11 @@ async function LogInUser (userInfo:any) {

async function LogInGitHub () {
try {
return await BaseClient.post('/auth/github/access_token/')
return await axios.post('/auth/github/access_token/')
} catch (error) {
console.error(error)
throw error
}
}

export default { AuthClient, BaseClient, LogInUser, LogInGitHub, SignUp, SignUpInvitation }
export default { LogInUser, LogInGitHub, SignUp, SignUpInvitation }
1 change: 1 addition & 0 deletions client/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ declare module 'vue' {
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Test: typeof import('./components/test.vue')['default']

}
}

0 comments on commit 1cf18f3

Please sign in to comment.