Skip to content

Commit 3e29cdf

Browse files
committed
feat: enable/disable user signup
1 parent f5a660b commit 3e29cdf

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inspatial/cloud",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"license": "Apache-2.0",
55
"exports": {
66
".": "./mod.ts",

src/auth/actions/google/handle-google-signup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { raiseServerException } from "~/serve/server-exception.ts";
1010
import type { User } from "../../entries/user/_user.type.ts";
1111
import type { Account } from "../../entries/account/_account.type.ts";
1212
import { handleGoogleLogin } from "./handle-google-login.ts";
13-
import type { SystemSettings } from "@inspatial/cloud/types";
13+
import type { SystemSettings } from "../../../extension/settings/_system-settings.type.ts";
1414

1515
export async function handleGoogleSignup(args: {
1616
accessToken: GoogleAccessTokenResponse;

src/auth/actions/register-account.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@ import { CloudAPIAction } from "~/api/cloud-action.ts";
22
import { raiseCloudException } from "~/serve/exeption/cloud-exception.ts";
33
import type { User } from "~/auth/entries/user/_user.type.ts";
44
import type { Account } from "~/auth/entries/account/_account.type.ts";
5+
import { SystemSettings } from "../../extension/settings/_system-settings.type.ts";
56

67
export const registerAccount = new CloudAPIAction("registerAccount", {
78
label: "Register Account",
89
description: "Create a new acount and assign the given user as the owner.",
910
authRequired: false,
1011
async run({ inCloud, orm, params, inRequest, inResponse }) {
12+
const { enableSignup } = await orm.getSettings<SystemSettings>(
13+
"systemSettings",
14+
);
15+
if (!enableSignup) {
16+
raiseCloudException("User signup is disabled", {
17+
type: "warning",
18+
});
19+
}
1120
const { firstName, lastName, email, password } = params;
1221
const existingUser = await orm.findEntry<User>("user", [{
1322
field: "email",

src/auth/actions/register-user.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import { CloudAPIAction } from "~/api/cloud-action.ts";
2+
import { raiseCloudException } from "../../serve/exeption/cloud-exception.ts";
3+
import type { SystemSettings } from "../../extension/settings/_system-settings.type.ts";
24

35
const registerUser = new CloudAPIAction("registerUser", {
46
description: "Register a new user",
57
hideFromApi: true,
68
async run({ orm, params }) {
9+
const { enableSignup } = await orm.getSettings<SystemSettings>(
10+
"systemSettings",
11+
);
12+
if (!enableSignup) {
13+
raiseCloudException("User signup is disabled", {
14+
type: "warning",
15+
});
16+
}
717
const { firstName, lastName, email, password } = params;
818
const user = await orm.createEntry("user", {
919
firstName,

0 commit comments

Comments
 (0)