1
0
Fork 0
mirror of synced 2024-06-30 20:10:54 +12:00

Fix backend-core redis imports.

This commit is contained in:
Sam Rose 2023-11-10 11:21:36 +00:00
parent 15767e2fd5
commit d98e217c6c
No known key found for this signature in database
4 changed files with 13 additions and 17 deletions

View file

@ -4,5 +4,6 @@ export { default as Client } from "./redis"
export * as utils from "./utils" export * as utils from "./utils"
export * as clients from "./init" export * as clients from "./init"
export * as locks from "./redlockImpl" export * as locks from "./redlockImpl"
export * as invite from "./invite"
export * as passwordReset from "./passwordReset" export * from "./invite"
export * from "./passwordReset"

View file

@ -1,9 +1,4 @@
import { import { redis } from "@budibase/backend-core"
getInviteCode,
deleteInviteCode,
getInviteCodes,
updateInviteCode,
} from "@budibase/backend-core/src/redis/invite"
import * as userSdk from "../../../sdk/users" import * as userSdk from "../../../sdk/users"
import env from "../../../environment" import env from "../../../environment"
import { import {
@ -313,7 +308,7 @@ export const checkInvite = async (ctx: any) => {
const { code } = ctx.params const { code } = ctx.params
let invite let invite
try { try {
invite = await getInviteCode(code) invite = await redis.getInviteCode(code)
} catch (e) { } catch (e) {
console.warn("Error getting invite from code", e) console.warn("Error getting invite from code", e)
ctx.throw(400, "There was a problem with the invite") ctx.throw(400, "There was a problem with the invite")
@ -327,7 +322,7 @@ export const checkInvite = async (ctx: any) => {
export const getUserInvites = async (ctx: any) => { export const getUserInvites = async (ctx: any) => {
try { try {
// Restricted to the currently authenticated tenant // Restricted to the currently authenticated tenant
ctx.body = await getInviteCodes() ctx.body = await redis.getInviteCodes()
} catch (e) { } catch (e) {
ctx.throw(400, "There was a problem fetching invites") ctx.throw(400, "There was a problem fetching invites")
} }
@ -341,7 +336,7 @@ export const updateInvite = async (ctx: any) => {
let invite let invite
try { try {
invite = await getInviteCode(code) invite = await redis.getInviteCode(code)
} catch (e) { } catch (e) {
ctx.throw(400, "There was a problem with the invite") ctx.throw(400, "There was a problem with the invite")
return return
@ -369,7 +364,7 @@ export const updateInvite = async (ctx: any) => {
} }
} }
await updateInviteCode(code, updated) await redis.updateInviteCode(code, updated)
ctx.body = { ...invite } ctx.body = { ...invite }
} }
@ -379,8 +374,8 @@ export const inviteAccept = async (
const { inviteCode, password, firstName, lastName } = ctx.request.body const { inviteCode, password, firstName, lastName } = ctx.request.body
try { try {
// info is an extension of the user object that was stored by global // info is an extension of the user object that was stored by global
const { email, info }: any = await getInviteCode(inviteCode) const { email, info }: any = await redis.getInviteCode(inviteCode)
await deleteInviteCode(inviteCode) await redis.deleteInviteCode(inviteCode)
const user = await tenancy.doInTenant(info.tenantId, async () => { const user = await tenancy.doInTenant(info.tenantId, async () => {
let request: any = { let request: any = {
firstName, firstName,

View file

@ -73,7 +73,7 @@ export const reset = async (email: string) => {
* Perform the user password update if the provided reset code is valid. * Perform the user password update if the provided reset code is valid.
*/ */
export const resetUpdate = async (resetCode: string, password: string) => { export const resetUpdate = async (resetCode: string, password: string) => {
const { userId } = await redis.passwordReset.getResetPasswordCode(resetCode) const { userId } = await redis.getResetPasswordCode(resetCode)
let user = await userSdk.db.getUser(userId) let user = await userSdk.db.getUser(userId)
user.password = password user.password = password

View file

@ -4,7 +4,7 @@ import { getTemplateByPurpose, EmailTemplates } from "../constants/templates"
import { getSettingsTemplateContext } from "./templates" import { getSettingsTemplateContext } from "./templates"
import { processString } from "@budibase/string-templates" import { processString } from "@budibase/string-templates"
import { createResetPasswordCode } from "@budibase/backend-core/src/redis/passwordReset" import { createResetPasswordCode } from "@budibase/backend-core/src/redis/passwordReset"
import { createInviteCode } from "@budibase/backend-core/src/redis/invite" import { redis } from "@budibase/backend-core"
import { User, SendEmailOpts, SMTPInnerConfig } from "@budibase/types" import { User, SendEmailOpts, SMTPInnerConfig } from "@budibase/types"
import { configs } from "@budibase/backend-core" import { configs } from "@budibase/backend-core"
import ical from "ical-generator" import ical from "ical-generator"
@ -64,7 +64,7 @@ async function getLinkCode(
case EmailTemplatePurpose.PASSWORD_RECOVERY: case EmailTemplatePurpose.PASSWORD_RECOVERY:
return createResetPasswordCode(user._id!, info) return createResetPasswordCode(user._id!, info)
case EmailTemplatePurpose.INVITATION: case EmailTemplatePurpose.INVITATION:
return createInviteCode(email, info) return redis.createInviteCode(email, info)
default: default:
return null return null
} }