Skip to content

Commit

Permalink
fix: use const for config
Browse files Browse the repository at this point in the history
  • Loading branch information
marlenetienne committed Feb 10, 2025
1 parent b69bf9c commit dfe0e21
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
23 changes: 23 additions & 0 deletions src/shared/const/authConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { getEnvVariables } from '@/envVariables.ts';

interface AuthConfig {
authority: string;
client_id: string;
redirect_uri: string;
scope: string;
maxExpiresIn: number;
}

export const config: AuthConfig = {
client_id: getEnvVariables('VITE_OAUTH2_CLIENT_ID'),
redirect_uri: getEnvVariables('VITE_OAUTH2_REDIRECT_URL'),
authority: getEnvVariables('VITE_OAUTH2_REDIRECT_URL'),
scope: 'openid email profile',
maxExpiresIn: 600,
};
18 changes: 1 addition & 17 deletions src/shared/services/authService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,7 @@
*/

import { User, UserManager } from 'oidc-client-ts';
import { getEnvVariables } from '@/envVariables.ts';

interface AuthConfig {
authority: string;
client_id: string;
redirect_uri: string;
scope: string;
maxExpiresIn: number;
}

const config: AuthConfig = {
client_id: getEnvVariables('VITE_OAUTH2_CLIENT_ID'),
redirect_uri: getEnvVariables('VITE_OAUTH2_REDIRECT_URL'),
authority: getEnvVariables('VITE_OAUTH2_REDIRECT_URL'),
scope: 'openid email profile',
maxExpiresIn: 600,
};
import { config } from '@/shared/const/authConfig';

const userManager = new UserManager(config);

Expand Down
2 changes: 1 addition & 1 deletion src/store/contexts/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { createContext, ReactNode, useContext, useEffect, useState } from 'react';
import { UserState } from '@/shared/types';
import { AuthService } from '@/shared/services/authService.ts';
import { AuthService } from '@/shared/services/authService';

const initialState: UserState = {
user: null,
Expand Down

0 comments on commit dfe0e21

Please sign in to comment.