mirror of
https://github.com/p-stream/backend.git
synced 2026-01-11 12:00:45 +00:00
alert if no crypto secret
also fix typo
This commit is contained in:
parent
255a002c2b
commit
a24f27679e
2 changed files with 22 additions and 3 deletions
|
|
@ -31,7 +31,7 @@ export default defineNitroConfig({
|
|||
tmdbApiKey: process.env.TMDB_API_KEY,
|
||||
trakt: {
|
||||
clientId: process.env.TRAKT_CLIENT_ID,
|
||||
clientSecret: process.env.TRAKT_CLIENT_SECRET,
|
||||
clientSecret: process.env.TRAKT_SECRET_ID,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -55,7 +55,19 @@ export function useAuth() {
|
|||
|
||||
const makeSessionToken = (session: { id: string }) => {
|
||||
const runtimeConfig = useRuntimeConfig();
|
||||
return sign({ sid: session.id }, runtimeConfig.cryptoSecret, {
|
||||
const cryptoSecret = runtimeConfig.cryptoSecret || process.env.CRYPTO_SECRET;
|
||||
|
||||
if (!cryptoSecret) {
|
||||
console.error('CRYPTO_SECRET is missing from both runtime config and environment');
|
||||
console.error('Available runtime config keys:', Object.keys(runtimeConfig));
|
||||
console.error('Environment variables:', {
|
||||
CRYPTO_SECRET: process.env.CRYPTO_SECRET ? 'SET' : 'NOT SET',
|
||||
NODE_ENV: process.env.NODE_ENV,
|
||||
});
|
||||
throw new Error('CRYPTO_SECRET environment variable is not set');
|
||||
}
|
||||
|
||||
return sign({ sid: session.id }, cryptoSecret, {
|
||||
algorithm: 'HS256',
|
||||
});
|
||||
};
|
||||
|
|
@ -63,7 +75,14 @@ export function useAuth() {
|
|||
const verifySessionToken = (token: string) => {
|
||||
try {
|
||||
const runtimeConfig = useRuntimeConfig();
|
||||
const payload = verify(token, runtimeConfig.cryptoSecret, {
|
||||
const cryptoSecret = runtimeConfig.cryptoSecret || process.env.CRYPTO_SECRET;
|
||||
|
||||
if (!cryptoSecret) {
|
||||
console.error('CRYPTO_SECRET is missing for token verification');
|
||||
return null;
|
||||
}
|
||||
|
||||
const payload = verify(token, cryptoSecret, {
|
||||
algorithms: ['HS256'],
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue