Skip to content

Commit

Permalink
feat: add embed iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
darlanalves authored Jul 30, 2024
1 parent 7999940 commit f964298
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/passport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import passport, { Profile } from "passport";
import { randomUUID } from "crypto";
import { Strategy as GoogleStrategy } from "passport-google-oauth20";
import { User, toJSON, findByProfileId, findByUserId } from "./user.js";
import log from './log.js';

export const callback = "/auth/google/callback";

Expand All @@ -19,7 +18,6 @@ passport.use(
profile: Profile,
done: any
) {
log("User authenticated:", profile.id);
let user = await findByProfileId(profile.id);

if (!user) {
Expand Down Expand Up @@ -58,7 +56,6 @@ passport.deserializeUser(async (id: string, done: any) => {

return done(new Error("Not found"));
} catch (error) {
log("deserialize", error);
done(new Error(String(error)));
}
});
Expand Down
12 changes: 11 additions & 1 deletion src/session.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import session from "express-session";

const { SESSION_SECRET = "", SESSION_DOMAIN = "" } = process.env;
const {
SESSION_SECRET = "",
SESSION_DOMAIN = "",
SESSION_COOKIE_SAMESITE = "",
SESSION_COOKIE_SECURE = ""
} = process.env;

const sessionOptions: session.SessionOptions = {
secret: SESSION_SECRET,
Expand All @@ -9,9 +14,14 @@ const sessionOptions: session.SessionOptions = {
};

if (SESSION_DOMAIN) {
const sameSite = SESSION_COOKIE_SAMESITE ? SESSION_COOKIE_SECURE as session.SessionOptions['cookie']['sameSite'] : false;
const secure = !!SESSION_COOKIE_SECURE;

sessionOptions.cookie = {
domain: SESSION_DOMAIN,
httpOnly: true,
sameSite,
secure,
};
}

Expand Down
3 changes: 0 additions & 3 deletions src/user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import log from './log.js';
import {
Model,
Primary,
Expand Down Expand Up @@ -36,7 +35,6 @@ export async function initUser() {
}

export async function findByProfileId(profileId: string) {
log('findByProfileId', profileId);
const all = await Resource.find(
User,
new Query<User>().where("profileId").is(String(profileId))
Expand All @@ -45,7 +43,6 @@ export async function findByProfileId(profileId: string) {
}

export async function findByUserId(userId: string) {
log('findByUserId', userId);
const all = await Resource.find(
User,
new Query<User>().where("userId").is(String(userId))
Expand Down

0 comments on commit f964298

Please sign in to comment.