Skip to content

Commit

Permalink
fix: skip email verify for self hosting (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored May 6, 2024
1 parent a761d83 commit b4811b5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/backend/src/api/v1/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
verifyJWT,
verifyPassword,
} from "./utils"
import config from "@/src/utils/config"

const auth = new Router({
prefix: "/auth",
Expand Down Expand Up @@ -104,7 +105,7 @@ auth.post("/signup", async (ctx: Context) => {
email,
orgId: org.id,
role: "owner",
verified: !process.env.RESEND_KEY ? true : false,
verified: config.skipEmailVerify,
lastLoginAt: new Date(),
}

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/api/v1/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { signJWT } from "./auth/utils"
import { roles } from "shared"
import { checkAccess } from "@/src/utils/authorization"
import Context from "@/src/utils/koa"
import config from "@/src/utils/config"

const users = new Router({
prefix: "/users",
Expand Down Expand Up @@ -192,7 +193,7 @@ users.post("/", checkAccess("teamMembers", "create"), async (ctx: Context) => {
email,
orgId,
role,
verified: false,
verified: config.skipEmailVerify,
singleUseToken: token,
}

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ app.use(ratelimit)
app.use(bodyParser({ jsonLimit: "5mb", textLimit: "5mb" }))
app.use(setDefaultBody)

if (config.IS_SELF_HOSTED) {
if (config.isSelfHosted) {
app.use(licenseMiddleware)
}

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const config = {
IS_SELF_HOSTED: process.env.IS_SELF_HOSTED === "true" ? true : false,
isSelfHosted: process.env.IS_SELF_HOSTED === "true" ? true : false,
skipEmailVerify: process.env.SKIP_EMAIL_VERIFY === "true" ? true : false,
}

export default config

0 comments on commit b4811b5

Please sign in to comment.