Skip to content

Commit

Permalink
chore: eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoidPhantom committed Aug 7, 2024
1 parent 794d287 commit 02372b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
23 changes: 8 additions & 15 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
defineNuxtModule,
createResolver,
addComponent,
addPlugin,
addImports,
addServerHandler,
} from "@nuxt/kit";
import { defineNuxtModule, createResolver, addComponent, addPlugin, addImports } from "@nuxt/kit";
import { defu } from "defu";

export interface ModuleOptions {
Expand All @@ -23,10 +16,10 @@ export default defineNuxtModule<ModuleOptions>({
},
setup(_options, _nuxt) {
const resolver = createResolver(import.meta.url);
const token =
process.env.TG_BOT_TOKEN ??
_options.token ??
(_nuxt.options.runtimeConfig.tgauth as ModuleOptions).token;
const token
= process.env.TG_BOT_TOKEN
?? _options.token
?? (_nuxt.options.runtimeConfig.tgauth as ModuleOptions).token;
if (!token) throw new Error("TG_BOT_TOKEN envirnoment variable is not set");
else
_nuxt.options.runtimeConfig.tgauth = defu(
Expand All @@ -35,9 +28,9 @@ export default defineNuxtModule<ModuleOptions>({
token,
},
);
const expiration =
_options.auth_expiration ??
(_nuxt.options.runtimeConfig.tgauth as ModuleOptions).auth_expiration;
const expiration
= _options.auth_expiration
?? (_nuxt.options.runtimeConfig.tgauth as ModuleOptions).auth_expiration;
if (expiration)
_nuxt.options.runtimeConfig.tgauth = defu(
_nuxt.options.runtimeConfig.tgauth as ModuleOptions,
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/server/services/serverTelegramUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const serverTgauthUser = async (
event.context._tgauthUser = {
valid: false,
};

try {
const authObjectString = getCookie(event, "TG_AUTH_USER");
const { tgauth } = useRuntimeConfig();
Expand Down Expand Up @@ -63,8 +63,8 @@ export const serverTgauthUser = async (
// Return bool value is valid

const valid = Boolean(
hashGenerate === hash &&
(tgauth.auth_expiration === 0 || age < (tgauth.auth_expiration ?? 14 * 24 * 60 * 60)), // Invalidate after 14 days by default
hashGenerate === hash
&& (tgauth.auth_expiration === 0 || age < (tgauth.auth_expiration ?? 14 * 24 * 60 * 60)), // Invalidate after 14 days by default
);
event.context._tgauthUser.valid = valid;
event.context._tgauthUser.user = authObject;
Expand Down

0 comments on commit 02372b9

Please sign in to comment.