Compare commits
1 Commits
feat/plain
...
1.1.27-bet
Author | SHA1 | Date | |
---|---|---|---|
![]() |
19f9caf478 |
28
.github/workflows/release.yaml
vendored
28
.github/workflows/release.yaml
vendored
@@ -2,16 +2,16 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
logLevel:
|
logLevel:
|
||||||
description: 'Log level'
|
description: "Log level"
|
||||||
required: true
|
required: true
|
||||||
default: 'warning'
|
default: "warning"
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
- info
|
- info
|
||||||
- warning
|
- warning
|
||||||
- debug
|
- debug
|
||||||
tags:
|
tags:
|
||||||
description: 'Tags'
|
description: "Tags"
|
||||||
required: false
|
required: false
|
||||||
type: boolean
|
type: boolean
|
||||||
release:
|
release:
|
||||||
@@ -25,10 +25,19 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
node-version: "16"
|
||||||
|
- # Add support for more platforms with QEMU (optional)
|
||||||
|
# https://github.com/docker/setup-qemu-action
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
buildkitd-flags: --debug
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: '^1.17.3'
|
go-version: "^1.17.3"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install build-essential wget zip gcc-mingw-w64 && \
|
sudo apt-get install build-essential wget zip gcc-mingw-w64 && \
|
||||||
@@ -59,10 +68,16 @@ jobs:
|
|||||||
make clean && \
|
make clean && \
|
||||||
CGO_ENABLED=1 make && \
|
CGO_ENABLED=1 make && \
|
||||||
tar cvfz authorizer-${VERSION}-linux-amd64.tar.gz .env app/build build templates dashboard/build
|
tar cvfz authorizer-${VERSION}-linux-amd64.tar.gz .env app/build build templates dashboard/build
|
||||||
|
- name: Build package
|
||||||
|
run: |
|
||||||
|
make clean && \
|
||||||
|
make build && \
|
||||||
|
mkdir -p authorizer-${VERSION}-darwin-amd64/build authorizer-${VERSION}-darwin-amd64/app authorizer-${VERSION}-darwin-amd64/templates authorizer-${VERSION}-darwin-amd64/dashboard && cp build/darwin/amd64/server authorizer-${VERSION}-darwin-amd64/build/ && cp .env authorizer-${VERSION}-darwin-amd64/.env && cp -rf app/build authorizer-${VERSION}-darwin-amd64/app/build && cp -rf templates authorizer-${VERSION}-darwin-amd64/templates && cp -rf dashboard/build authorizer-${VERSION}-darwin-amd64/dashboard/build && tar cvfz authorizer-${VERSION}-darwin-amd64.tar.gz authorizer-${VERSION}-darwin-amd64
|
||||||
- name: Upload assets
|
- name: Upload assets
|
||||||
run: |
|
run: |
|
||||||
github-assets-uploader -f authorizer-${VERSION}-windows-amd64.zip -mediatype application/zip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION} && \
|
github-assets-uploader -f authorizer-${VERSION}-windows-amd64.zip -mediatype application/zip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION} && \
|
||||||
github-assets-uploader -f authorizer-${VERSION}-linux-amd64.tar.gz -mediatype application/gzip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION}
|
github-assets-uploader -f authorizer-${VERSION}-linux-amd64.tar.gz -mediatype application/gzip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION}
|
||||||
|
github-assets-uploader -f authorizer-${VERSION}-darwin-amd64.tar.gz -mediatype application/gzip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION}
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
@@ -74,6 +89,9 @@ jobs:
|
|||||||
uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v3
|
||||||
with:
|
with:
|
||||||
images: lakhansamani/authorizer
|
images: lakhansamani/authorizer
|
||||||
|
tags: |
|
||||||
|
# set latest tag for default branch
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
|
6
Makefile
6
Makefile
@@ -3,6 +3,12 @@ VERSION := $(or $(VERSION),$(DEFAULT_VERSION))
|
|||||||
|
|
||||||
cmd:
|
cmd:
|
||||||
cd server && go build -ldflags "-w -X main.VERSION=$(VERSION)" -o '../build/server'
|
cd server && go build -ldflags "-w -X main.VERSION=$(VERSION)" -o '../build/server'
|
||||||
|
build:
|
||||||
|
cd server && gox \
|
||||||
|
-osarch="linux/amd64 linux/arm64 darwin/amd64 windows/386 windows/amd64" \
|
||||||
|
-ldflags "-w -X main.VERSION=$(VERSION)" \
|
||||||
|
-output="../build/{{.OS}}/{{.Arch}}/server" \
|
||||||
|
./...
|
||||||
build-app:
|
build-app:
|
||||||
cd app && npm i && npm run build
|
cd app && npm i && npm run build
|
||||||
build-dashboard:
|
build-dashboard:
|
||||||
|
1079
dashboard/package-lock.json
generated
1079
dashboard/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -29,10 +29,6 @@ import {
|
|||||||
Tbody,
|
Tbody,
|
||||||
Td,
|
Td,
|
||||||
Code,
|
Code,
|
||||||
Radio,
|
|
||||||
RadioGroup,
|
|
||||||
Stack,
|
|
||||||
Textarea,
|
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { FaPlus, FaAngleDown, FaAngleUp } from 'react-icons/fa';
|
import { FaPlus, FaAngleDown, FaAngleUp } from 'react-icons/fa';
|
||||||
import { useClient } from 'urql';
|
import { useClient } from 'urql';
|
||||||
@@ -42,7 +38,6 @@ import {
|
|||||||
EmailTemplateInputDataFields,
|
EmailTemplateInputDataFields,
|
||||||
emailTemplateEventNames,
|
emailTemplateEventNames,
|
||||||
emailTemplateVariables,
|
emailTemplateVariables,
|
||||||
EmailTemplateEditors,
|
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
import { capitalizeFirstLetter } from '../utils';
|
import { capitalizeFirstLetter } from '../utils';
|
||||||
import { AddEmailTemplate, EditEmailTemplate } from '../graphql/mutation';
|
import { AddEmailTemplate, EditEmailTemplate } from '../graphql/mutation';
|
||||||
@@ -71,8 +66,6 @@ interface templateVariableDataTypes {
|
|||||||
interface emailTemplateDataType {
|
interface emailTemplateDataType {
|
||||||
[EmailTemplateInputDataFields.EVENT_NAME]: string;
|
[EmailTemplateInputDataFields.EVENT_NAME]: string;
|
||||||
[EmailTemplateInputDataFields.SUBJECT]: string;
|
[EmailTemplateInputDataFields.SUBJECT]: string;
|
||||||
[EmailTemplateInputDataFields.TEMPLATE]: string;
|
|
||||||
[EmailTemplateInputDataFields.DESIGN]: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface validatorDataType {
|
interface validatorDataType {
|
||||||
@@ -82,8 +75,6 @@ interface validatorDataType {
|
|||||||
const initTemplateData: emailTemplateDataType = {
|
const initTemplateData: emailTemplateDataType = {
|
||||||
[EmailTemplateInputDataFields.EVENT_NAME]: emailTemplateEventNames.Signup,
|
[EmailTemplateInputDataFields.EVENT_NAME]: emailTemplateEventNames.Signup,
|
||||||
[EmailTemplateInputDataFields.SUBJECT]: '',
|
[EmailTemplateInputDataFields.SUBJECT]: '',
|
||||||
[EmailTemplateInputDataFields.TEMPLATE]: '',
|
|
||||||
[EmailTemplateInputDataFields.DESIGN]: '',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const initTemplateValidatorData: validatorDataType = {
|
const initTemplateValidatorData: validatorDataType = {
|
||||||
@@ -100,9 +91,6 @@ const UpdateEmailTemplate = ({
|
|||||||
const emailEditorRef = useRef(null);
|
const emailEditorRef = useRef(null);
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
const [editor, setEditor] = useState<string>(
|
|
||||||
EmailTemplateEditors.PLAIN_HTML_EDITOR,
|
|
||||||
);
|
|
||||||
const [templateVariables, setTemplateVariables] = useState<
|
const [templateVariables, setTemplateVariables] = useState<
|
||||||
templateVariableDataTypes[]
|
templateVariableDataTypes[]
|
||||||
>([]);
|
>([]);
|
||||||
@@ -119,11 +107,9 @@ const UpdateEmailTemplate = ({
|
|||||||
if (selectedTemplate) {
|
if (selectedTemplate) {
|
||||||
const { design } = selectedTemplate;
|
const { design } = selectedTemplate;
|
||||||
try {
|
try {
|
||||||
if (design) {
|
|
||||||
const designData = JSON.parse(design);
|
const designData = JSON.parse(design);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
emailEditorRef.current.editor.loadDesign(designData);
|
emailEditorRef.current.editor.loadDesign(designData);
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
onClose();
|
onClose();
|
||||||
@@ -150,7 +136,24 @@ const UpdateEmailTemplate = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateTemplate = async (params: emailTemplateDataType) => {
|
const saveData = async () => {
|
||||||
|
if (!validateData()) return;
|
||||||
|
setLoading(true);
|
||||||
|
// @ts-ignore
|
||||||
|
return await emailEditorRef.current.editor.exportHtml(async (data) => {
|
||||||
|
const { design, html } = data;
|
||||||
|
if (!html || !design) {
|
||||||
|
setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const params = {
|
||||||
|
[EmailTemplateInputDataFields.EVENT_NAME]:
|
||||||
|
templateData[EmailTemplateInputDataFields.EVENT_NAME],
|
||||||
|
[EmailTemplateInputDataFields.SUBJECT]:
|
||||||
|
templateData[EmailTemplateInputDataFields.SUBJECT],
|
||||||
|
[EmailTemplateInputDataFields.TEMPLATE]: html.trim(),
|
||||||
|
[EmailTemplateInputDataFields.DESIGN]: JSON.stringify(design),
|
||||||
|
};
|
||||||
let res: any = {};
|
let res: any = {};
|
||||||
if (
|
if (
|
||||||
view === UpdateModalViews.Edit &&
|
view === UpdateModalViews.Edit &&
|
||||||
@@ -194,41 +197,9 @@ const UpdateEmailTemplate = ({
|
|||||||
setValidator({ ...initTemplateValidatorData });
|
setValidator({ ...initTemplateValidatorData });
|
||||||
fetchEmailTemplatesData();
|
fetchEmailTemplatesData();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
const saveData = async () => {
|
|
||||||
if (!validateData()) return;
|
|
||||||
setLoading(true);
|
|
||||||
let params: emailTemplateDataType = {
|
|
||||||
[EmailTemplateInputDataFields.EVENT_NAME]:
|
|
||||||
templateData[EmailTemplateInputDataFields.EVENT_NAME],
|
|
||||||
[EmailTemplateInputDataFields.SUBJECT]:
|
|
||||||
templateData[EmailTemplateInputDataFields.SUBJECT],
|
|
||||||
[EmailTemplateInputDataFields.TEMPLATE]:
|
|
||||||
templateData[EmailTemplateInputDataFields.TEMPLATE],
|
|
||||||
[EmailTemplateInputDataFields.DESIGN]: '',
|
|
||||||
};
|
|
||||||
if (editor === EmailTemplateEditors.UNLAYER_EDITOR) {
|
|
||||||
// @ts-ignore
|
|
||||||
await emailEditorRef.current.editor.exportHtml(async (data) => {
|
|
||||||
const { design, html } = data;
|
|
||||||
if (!html || !design) {
|
|
||||||
setLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
params = {
|
|
||||||
...params,
|
|
||||||
[EmailTemplateInputDataFields.TEMPLATE]: html.trim(),
|
|
||||||
[EmailTemplateInputDataFields.DESIGN]: JSON.stringify(design),
|
|
||||||
};
|
|
||||||
await updateTemplate(params);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await updateTemplate(params);
|
|
||||||
}
|
|
||||||
view === UpdateModalViews.ADD && onClose();
|
view === UpdateModalViews.ADD && onClose();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const resetData = () => {
|
const resetData = () => {
|
||||||
if (selectedTemplate) {
|
if (selectedTemplate) {
|
||||||
setTemplateData(selectedTemplate);
|
setTemplateData(selectedTemplate);
|
||||||
@@ -236,8 +207,6 @@ const UpdateEmailTemplate = ({
|
|||||||
setTemplateData({ ...initTemplateData });
|
setTemplateData({ ...initTemplateData });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// set template data if edit modal is open
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
isOpen &&
|
isOpen &&
|
||||||
@@ -245,12 +214,10 @@ const UpdateEmailTemplate = ({
|
|||||||
selectedTemplate &&
|
selectedTemplate &&
|
||||||
Object.keys(selectedTemplate || {}).length
|
Object.keys(selectedTemplate || {}).length
|
||||||
) {
|
) {
|
||||||
const { id, created_at, ...rest } = selectedTemplate;
|
const { id, created_at, template, design, ...rest } = selectedTemplate;
|
||||||
setTemplateData(rest);
|
setTemplateData(rest);
|
||||||
}
|
}
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|
||||||
// set template variables
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const updatedTemplateVariables = Object.entries(
|
const updatedTemplateVariables = Object.entries(
|
||||||
emailTemplateVariables,
|
emailTemplateVariables,
|
||||||
@@ -277,51 +244,6 @@ const UpdateEmailTemplate = ({
|
|||||||
setTemplateVariables(updatedTemplateVariables);
|
setTemplateVariables(updatedTemplateVariables);
|
||||||
}, [templateData[EmailTemplateInputDataFields.EVENT_NAME]]);
|
}, [templateData[EmailTemplateInputDataFields.EVENT_NAME]]);
|
||||||
|
|
||||||
// change editor
|
|
||||||
useEffect(() => {
|
|
||||||
if (isOpen && selectedTemplate) {
|
|
||||||
const { design } = selectedTemplate;
|
|
||||||
if (design) {
|
|
||||||
setEditor(EmailTemplateEditors.UNLAYER_EDITOR);
|
|
||||||
} else {
|
|
||||||
setEditor(EmailTemplateEditors.PLAIN_HTML_EDITOR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [isOpen, selectedTemplate]);
|
|
||||||
|
|
||||||
// reset fields when editor is changed
|
|
||||||
useEffect(() => {
|
|
||||||
if (selectedTemplate?.design) {
|
|
||||||
if (editor === EmailTemplateEditors.UNLAYER_EDITOR) {
|
|
||||||
setTemplateData({
|
|
||||||
...templateData,
|
|
||||||
[EmailTemplateInputDataFields.TEMPLATE]: selectedTemplate.template,
|
|
||||||
[EmailTemplateInputDataFields.DESIGN]: selectedTemplate.design,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setTemplateData({
|
|
||||||
...templateData,
|
|
||||||
[EmailTemplateInputDataFields.TEMPLATE]: '',
|
|
||||||
[EmailTemplateInputDataFields.DESIGN]: '',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (selectedTemplate?.template) {
|
|
||||||
if (editor === EmailTemplateEditors.UNLAYER_EDITOR) {
|
|
||||||
setTemplateData({
|
|
||||||
...templateData,
|
|
||||||
[EmailTemplateInputDataFields.TEMPLATE]: '',
|
|
||||||
[EmailTemplateInputDataFields.DESIGN]: '',
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setTemplateData({
|
|
||||||
...templateData,
|
|
||||||
[EmailTemplateInputDataFields.TEMPLATE]: selectedTemplate?.template,
|
|
||||||
[EmailTemplateInputDataFields.DESIGN]: '',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [editor]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{view === UpdateModalViews.ADD ? (
|
{view === UpdateModalViews.ADD ? (
|
||||||
@@ -492,22 +414,7 @@ const UpdateEmailTemplate = ({
|
|||||||
alignItems="center"
|
alignItems="center"
|
||||||
marginBottom="2%"
|
marginBottom="2%"
|
||||||
>
|
>
|
||||||
<Flex flex="1">Template Body</Flex>
|
Template Body
|
||||||
<Flex flex="3">
|
|
||||||
<RadioGroup
|
|
||||||
onChange={(value) => setEditor(value)}
|
|
||||||
value={editor}
|
|
||||||
>
|
|
||||||
<Stack direction="row" spacing="50px">
|
|
||||||
<Radio value={EmailTemplateEditors.PLAIN_HTML_EDITOR}>
|
|
||||||
Plain HTML
|
|
||||||
</Radio>
|
|
||||||
<Radio value={EmailTemplateEditors.UNLAYER_EDITOR}>
|
|
||||||
Unlayer Editor
|
|
||||||
</Radio>
|
|
||||||
</Stack>
|
|
||||||
</RadioGroup>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex
|
<Flex
|
||||||
width="100%"
|
width="100%"
|
||||||
@@ -516,22 +423,7 @@ const UpdateEmailTemplate = ({
|
|||||||
border="1px solid"
|
border="1px solid"
|
||||||
borderColor="gray.200"
|
borderColor="gray.200"
|
||||||
>
|
>
|
||||||
{editor === EmailTemplateEditors.UNLAYER_EDITOR ? (
|
|
||||||
<EmailEditor ref={emailEditorRef} onReady={onReady} />
|
<EmailEditor ref={emailEditorRef} onReady={onReady} />
|
||||||
) : (
|
|
||||||
<Textarea
|
|
||||||
value={templateData.template}
|
|
||||||
onChange={(e) => {
|
|
||||||
setTemplateData({
|
|
||||||
...templateData,
|
|
||||||
[EmailTemplateInputDataFields.TEMPLATE]: e.target.value,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
placeholder="Template HTML"
|
|
||||||
border="0"
|
|
||||||
height="500px"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
|
@@ -337,8 +337,3 @@ export const webhookPayloadExample: string = `{
|
|||||||
},
|
},
|
||||||
"auth_recipe":"google"
|
"auth_recipe":"google"
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
export enum EmailTemplateEditors {
|
|
||||||
UNLAYER_EDITOR = 'unlayer_editor',
|
|
||||||
PLAIN_HTML_EDITOR = 'plain_html_editor',
|
|
||||||
}
|
|
||||||
|
@@ -17,6 +17,7 @@ require (
|
|||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/guregu/dynamo v1.16.0
|
github.com/guregu/dynamo v1.16.0
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.3.0
|
||||||
|
github.com/mitchellh/gox v1.0.1 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
||||||
github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f
|
github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f
|
||||||
|
@@ -195,6 +195,8 @@ github.com/guregu/dynamo v1.16.0 h1:gmI8oi1VHwYQtq7+RPBeOiSssVLgxH/Az2t+NtDtL2c=
|
|||||||
github.com/guregu/dynamo v1.16.0/go.mod h1:W2Gqcf3MtkrS+Q6fHPGAmRtT0Dyq+TGrqfqrUC9+R/c=
|
github.com/guregu/dynamo v1.16.0/go.mod h1:W2Gqcf3MtkrS+Q6fHPGAmRtT0Dyq+TGrqfqrUC9+R/c=
|
||||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
|
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
|
||||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
||||||
|
github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8=
|
||||||
|
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
|
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
|
||||||
@@ -300,6 +302,10 @@ github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peK
|
|||||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
|
github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
|
||||||
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||||
|
github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI=
|
||||||
|
github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4=
|
||||||
|
github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=
|
||||||
|
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||||
github.com/mitchellh/mapstructure v1.3.1 h1:cCBH2gTD2K0OtLlv/Y5H01VQCqmlDxz30kS5Y5bqfLA=
|
github.com/mitchellh/mapstructure v1.3.1 h1:cCBH2gTD2K0OtLlv/Y5H01VQCqmlDxz30kS5Y5bqfLA=
|
||||||
github.com/mitchellh/mapstructure v1.3.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
github.com/mitchellh/mapstructure v1.3.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
@@ -2395,7 +2395,7 @@ input AddEmailTemplateRequest {
|
|||||||
event_name: String!
|
event_name: String!
|
||||||
subject: String!
|
subject: String!
|
||||||
template: String!
|
template: String!
|
||||||
design: String
|
design: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
input UpdateEmailTemplateRequest {
|
input UpdateEmailTemplateRequest {
|
||||||
@@ -14130,7 +14130,7 @@ func (ec *executionContext) unmarshalInputAddEmailTemplateRequest(ctx context.Co
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("design"))
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("design"))
|
||||||
it.Design, err = ec.unmarshalOString2ᚖstring(ctx, v)
|
it.Design, err = ec.unmarshalNString2string(ctx, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return it, err
|
return it, err
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ type AddEmailTemplateRequest struct {
|
|||||||
EventName string `json:"event_name"`
|
EventName string `json:"event_name"`
|
||||||
Subject string `json:"subject"`
|
Subject string `json:"subject"`
|
||||||
Template string `json:"template"`
|
Template string `json:"template"`
|
||||||
Design *string `json:"design"`
|
Design string `json:"design"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddWebhookRequest struct {
|
type AddWebhookRequest struct {
|
||||||
|
@@ -430,7 +430,7 @@ input AddEmailTemplateRequest {
|
|||||||
event_name: String!
|
event_name: String!
|
||||||
subject: String!
|
subject: String!
|
||||||
template: String!
|
template: String!
|
||||||
design: String
|
design: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
input UpdateEmailTemplateRequest {
|
input UpdateEmailTemplateRequest {
|
||||||
|
@@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/authorizerdev/authorizer/server/db"
|
"github.com/authorizerdev/authorizer/server/db"
|
||||||
"github.com/authorizerdev/authorizer/server/db/models"
|
"github.com/authorizerdev/authorizer/server/db/models"
|
||||||
"github.com/authorizerdev/authorizer/server/graph/model"
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||||
"github.com/authorizerdev/authorizer/server/refs"
|
|
||||||
"github.com/authorizerdev/authorizer/server/token"
|
"github.com/authorizerdev/authorizer/server/token"
|
||||||
"github.com/authorizerdev/authorizer/server/utils"
|
"github.com/authorizerdev/authorizer/server/utils"
|
||||||
"github.com/authorizerdev/authorizer/server/validators"
|
"github.com/authorizerdev/authorizer/server/validators"
|
||||||
@@ -41,17 +40,15 @@ func AddEmailTemplateResolver(ctx context.Context, params model.AddEmailTemplate
|
|||||||
return nil, fmt.Errorf("empty template not allowed")
|
return nil, fmt.Errorf("empty template not allowed")
|
||||||
}
|
}
|
||||||
|
|
||||||
var design string
|
if strings.TrimSpace(params.Design) == "" {
|
||||||
|
return nil, fmt.Errorf("empty design not allowed")
|
||||||
if params.Design == nil || strings.TrimSpace(refs.StringValue(params.Design)) == "" {
|
|
||||||
design = ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = db.Provider.AddEmailTemplate(ctx, models.EmailTemplate{
|
_, err = db.Provider.AddEmailTemplate(ctx, models.EmailTemplate{
|
||||||
EventName: params.EventName,
|
EventName: params.EventName,
|
||||||
Template: params.Template,
|
Template: params.Template,
|
||||||
Subject: params.Subject,
|
Subject: params.Subject,
|
||||||
Design: design,
|
Design: params.Design,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("Failed to add email template: ", err)
|
log.Debug("Failed to add email template: ", err)
|
||||||
|
@@ -51,30 +51,16 @@ func addEmailTemplateTest(t *testing.T, s TestSetup) {
|
|||||||
assert.Nil(t, emailTemplate)
|
assert.Nil(t, emailTemplate)
|
||||||
})
|
})
|
||||||
|
|
||||||
var design string
|
t.Run("should not add email template with empty design", func(t *testing.T) {
|
||||||
design = ""
|
|
||||||
|
|
||||||
for _, eventType := range s.TestInfo.TestEmailTemplateEventTypes {
|
|
||||||
t.Run("should add email template with empty design for "+eventType, func(t *testing.T) {
|
|
||||||
emailTemplate, err := resolvers.AddEmailTemplateResolver(ctx, model.AddEmailTemplateRequest{
|
emailTemplate, err := resolvers.AddEmailTemplateResolver(ctx, model.AddEmailTemplateRequest{
|
||||||
EventName: eventType,
|
EventName: s.TestInfo.TestEmailTemplateEventTypes[0],
|
||||||
Template: "Test email",
|
Template: "test",
|
||||||
Subject: "Test email",
|
Subject: "test",
|
||||||
Design: &design,
|
Design: " ",
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.Error(t, err)
|
||||||
assert.NotNil(t, emailTemplate)
|
assert.Nil(t, emailTemplate)
|
||||||
assert.NotEmpty(t, emailTemplate.Message)
|
|
||||||
|
|
||||||
et, err := db.Provider.GetEmailTemplateByEventName(ctx, eventType)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.Equal(t, et.EventName, eventType)
|
|
||||||
assert.Equal(t, "Test email", et.Subject)
|
|
||||||
assert.Equal(t, "Test design", et.Design)
|
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
design = "Test design"
|
|
||||||
|
|
||||||
for _, eventType := range s.TestInfo.TestEmailTemplateEventTypes {
|
for _, eventType := range s.TestInfo.TestEmailTemplateEventTypes {
|
||||||
t.Run("should add email template for "+eventType, func(t *testing.T) {
|
t.Run("should add email template for "+eventType, func(t *testing.T) {
|
||||||
@@ -82,7 +68,7 @@ func addEmailTemplateTest(t *testing.T, s TestSetup) {
|
|||||||
EventName: eventType,
|
EventName: eventType,
|
||||||
Template: "Test email",
|
Template: "Test email",
|
||||||
Subject: "Test email",
|
Subject: "Test email",
|
||||||
Design: &design,
|
Design: "Test design",
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, emailTemplate)
|
assert.NotNil(t, emailTemplate)
|
||||||
|
Reference in New Issue
Block a user