Skip to content

Commit

Permalink
chore: remove logs, rollback to manifest after oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Nov 7, 2024
1 parent 701106e commit 0f39a31
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
13 changes: 10 additions & 3 deletions static/scripts/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ export class AuthService {
const hash = window.location.hash;
if (!hash) return null;

window.location.hash = "";
window.history.replaceState(null, "", window.location.pathname);

const params = new URLSearchParams(hash.substring(1));
const providerToken = params.get("provider_token");
if (!providerToken) {
Expand Down Expand Up @@ -58,6 +55,8 @@ export class AuthService {
}

public async signInWithGithub(): Promise<void> {
const search = window.location.search;
localStorage.setItem("manifest", search);
const { data } = await this.supabase.auth.signInWithOAuth({ provider: "github" });
if (!data) throw new Error("Failed to sign in with GitHub");
}
Expand All @@ -73,6 +72,14 @@ export class AuthService {
const session = await this.getSupabaseSession();
user = user || await this.getNewGitHubUser(session?.provider_token || null);

const preAuthManifest = localStorage.getItem("manifest");
const isUrlEmpty = !window.location.search || !window.location.hash;
if (preAuthManifest && isUrlEmpty && user) {
const search = localStorage.getItem("manifest");
localStorage.removeItem("manifest");
window.location.search = `${search}`;
}

if (user) {
button.textContent = `Sign out ${user.login}`;
button.addEventListener("click", async () => {
Expand Down
1 change: 0 additions & 1 deletion static/scripts/decode-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class ManifestDecoder {
if (!encodedManifestEnvelope) {
throw new Error("No encoded manifest found!");
}
console.log(encodedManifestEnvelope);
const encodedManifest = encodedManifestEnvelope["manifest"];
const decodedManifest = decodeURI(encodedManifest);

Expand Down
3 changes: 0 additions & 3 deletions static/scripts/render-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export class ManifestRenderer {
* commands": {
*/

console.trace(decodedManifest);
const decodedManifestKeys = Object.keys(decodedManifest);
let x = -1;
const limit = decodedManifestKeys.length;
Expand All @@ -39,8 +38,6 @@ export class ManifestRenderer {
_tableRow.appendChild(_tableDataHeader);
_tableRow.appendChild(_tableDataValue);

console.trace(_tableRow);

while (++x < limit) {
const tableRow = _tableRow.cloneNode(true) as HTMLTableRowElement;
const key = decodedManifestKeys[x];
Expand Down

0 comments on commit 0f39a31

Please sign in to comment.