Skip to content

Commit

Permalink
Fix auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Excellify committed Oct 25, 2024
1 parent 64fe972 commit 0d13971
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/apollo/apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { ApolloClient, ApolloLink, InMemoryCache, createHttpLink } from "@apollo

export const httpLink = createHttpLink({
uri: import.meta.env.VITE_APP_API_GQL,
credentials: "include",
});

const token = useConfig<string>("app.7tv.token");
const authLink = new ApolloLink((op, next) => {
const jwt = decodeJWT(token.value);
if (!jwt || jwt.exp * 1000 < Date.now()) {
if (!jwt || jwt.exp * 1000 < Date.now() || !jwt.sub) {
token.value = "";
return next(op);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/settings/SettingsMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<div
v-if="actor.token"
class="seventv-settings-sidebar-profile-logout seventv-settings-expanded"
@click="actor.logout()"
@click.stop="actor.logout"
>
<LogoutIcon />
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/common/Constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const UNICODE_TAG_0_REGEX = new RegExp(UNICODE_TAG_0, "g");

export const HOSTNAME_SUPPORTED_REGEXP = /([a-z0-9]+[.])*(youtube|kick)[.]com/;
export const SEVENTV_EMOTE_LINK = new RegExp(
"https?:\\/\\/(?:www\\.)?7tv.app\\/emotes\\/(?<emoteID>[0-9a-f]{24})",
"https?:\\/\\/(?:www\\.)?7tv.app\\/emotes\\/(?<emoteID>[0-7][0-9A-HJKMNP-TV-Z]{25})",
"i",
);
export const SEVENTV_EMOTE_ID = new RegExp("[0-9a-f]{24}");
Expand Down
4 changes: 2 additions & 2 deletions src/common/Roles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum SevenTVRoles {
ADMIN = "6102002eab1aa12bf648cfcd",
MODERATOR = "60724f65e93d828bf8858789",
ADMIN = "01FBQX1CXG000AP6N15FV4HKYD",
MODERATOR = "01F2Z8C8M8000EJFC2HFW8B1W9",
}
8 changes: 2 additions & 6 deletions src/composable/useActor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InjectionKey, inject, provide, reactive, toRaw, watch } from "vue";
import { InjectionKey, inject, nextTick, provide, reactive, toRaw, watch } from "vue";
import { useConfig } from "@/composable/useSettings";
import { userByConnectionQuery, userQuery } from "@/assets/gql/seventv.user.gql";
import { SubscriptionResponse, useEgVault } from "@/app/store/egvault";
Expand All @@ -23,11 +23,7 @@ class ActorContext {
}

logout(): void {
fetch(import.meta.env.VITE_APP_API + "/auth/logout", {
method: "POST",
credentials: "include",
}).then(() => {
// So the user can re-authenticate if needed
nextTick(() => {
this.token = "";
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/composable/useSetMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function useSetMutation(setID?: string): SetMutation {
() => ctx.user,
(u) => {
if (!u) return;
setID = u.connections?.find((s) => s.platform === ctx.platform)?.emote_set?.id;
setID = u.connections?.find((s) => s.platform === ctx.platform)?.emote_set_id;
},
{ immediate: true },
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ const actor = useActor();
const perms = [SevenTVRoles.ADMIN, SevenTVRoles.MODERATOR] as string[];
const commandEditAnySet: Twitch.ChatCommand = {
name: "letmemamageemoteset",
name: "letmemanageemoteset",
description: "<Mod> Lets you edit any 7TV emote set",
helpText: "",
permissionLevel: 0,
Expand Down
5 changes: 2 additions & 3 deletions src/types/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ declare namespace SevenTV {
}

interface JWT {
u: string;
v: number;
iss: string;
sub: string;
exp: number;
nbf: number;
iat: number;
jti: string;
}

interface EmoteSet {
Expand Down

0 comments on commit 0d13971

Please sign in to comment.