login/logout envs

This commit is contained in:
typescreep
2025-08-05 15:50:35 +03:00
parent 1b53df4c85
commit d70f47d2fe
5 changed files with 18 additions and 3 deletions

3
.env
View File

@@ -22,3 +22,6 @@ VITE_INSTANCES_RESOURCE_NAME=v1alpha1
VITE_BFF_URL=
VITE_NODE_TERMINAL_DEFAULT_PROFILE=baseline
VITE_LOGIN_URL=/oauth/token
VITE_LOGOUT_URL=/oauth/logout

View File

@@ -24,3 +24,6 @@ INSTANCES_RESOURCE_NAME=
BFF_URL=
NODE_TERMINAL_DEFAULT_PROFILE=
VITE_LOGIN_URL=
VITE_LOGOUT_URL=

View File

@@ -57,6 +57,9 @@ const BFF_URL = process.env.LOCAL === 'true' ? options?.BFF_URL : process.env.BF
const NODE_TERMINAL_DEFAULT_PROFILE =
process.env.LOCAL === 'true' ? options?.NODE_TERMINAL_DEFAULT_PROFILE : process.env.NODE_TERMINAL_DEFAULT_PROFILE
const LOGIN_URL = process.env.LOCAL === 'true' ? options?.LOGIN_URL : process.env.LOGIN_URL
const LOGOUT_URL = process.env.LOCAL === 'true' ? options?.LOGOUT_URL : process.env.LOGOUT_URL
const healthcheck = require('express-healthcheck')
const promBundle = require('express-prom-bundle')
@@ -176,7 +179,9 @@ app.get(`${basePrefix ? basePrefix : ''}/env.js`, (_, res) => {
INSTANCES_API_GROUP: ${JSON.stringify(INSTANCES_API_GROUP) || '"check envs"'},
INSTANCES_VERSION: ${JSON.stringify(INSTANCES_VERSION) || '"check envs"'},
INSTANCES_RESOURCE_NAME: ${JSON.stringify(INSTANCES_RESOURCE_NAME) || '"check envs"'},
NODE_TERMINAL_DEFAULT_PROFILE: ${JSON.stringify(NODE_TERMINAL_DEFAULT_PROFILE) || '"general"'}
NODE_TERMINAL_DEFAULT_PROFILE: ${JSON.stringify(NODE_TERMINAL_DEFAULT_PROFILE) || '"general"'},
LOGIN_URL: ${JSON.stringify(LOGIN_URL) || '"check envs"'},
LOGOUT_URL: ${JSON.stringify(LOGOUT_URL) || '"check envs"'}
}
`,
)

View File

@@ -1,12 +1,13 @@
import axios, { AxiosResponse } from 'axios'
import { TAuthResponse } from 'localTypes/auth'
import { LOGIN_URL, LOGOUT_URL } from 'constants/customizationApiGroupAndVersion'
import { handleError } from './handleResponse'
export const login = async (): Promise<TAuthResponse | undefined> => {
let response: AxiosResponse<TAuthResponse> | undefined
try {
response = await axios.get<TAuthResponse>('/oauth/token', { withCredentials: true })
response = await axios.get<TAuthResponse>(LOGIN_URL, { withCredentials: true })
} catch (error) {
handleError(error)
}
@@ -18,7 +19,7 @@ export const logout = async (): Promise<TAuthResponse | undefined> => {
let response: AxiosResponse<TAuthResponse> | undefined
try {
response = await axios.get<TAuthResponse>('/oauth/logout', { withCredentials: true })
response = await axios.get<TAuthResponse>(LOGOUT_URL, { withCredentials: true })
} catch (error) {
handleError(error)
} finally {

View File

@@ -28,3 +28,6 @@ export const BASE_INSTANCES_RESOURCE_NAME =
export const NODE_TERMINAL_DEFAULT_PROFILE =
window._env_.NODE_TERMINAL_DEFAULT_PROFILE || import.meta.env.VITE_NODE_TERMINAL_DEFAULT_PROFILE
export const LOGIN_URL = window._env_.LOGIN_URL || import.meta.env.VITE_LOGIN_URL
export const LOGOUT_URL = window._env_.LOGOUT_URL || import.meta.env.VITE_LOGOUT_URL