diff --git a/admin-ui/package-lock.json b/admin-ui/package-lock.json
index 9457d6a..0c43b07 100644
--- a/admin-ui/package-lock.json
+++ b/admin-ui/package-lock.json
@@ -1,10 +1,10 @@
{
- "name": "my-app-45-admin",
+ "name": "my-app-44-admin",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
- "name": "my-app-45-admin",
+ "name": "my-app-44-admin",
"dependencies": {
"@apollo/client": "^3.3.18",
"@material-ui/core": "^4.11.4",
diff --git a/admin-ui/package.json b/admin-ui/package.json
index 5ecaa81..7092ccc 100644
--- a/admin-ui/package.json
+++ b/admin-ui/package.json
@@ -1,5 +1,5 @@
{
- "name": "my-app-45-admin",
+ "name": "my-app-44-admin",
"private": true,
"dependencies": {
"@apollo/client": "^3.3.18",
diff --git a/admin-ui/public/index.html b/admin-ui/public/index.html
index 896a28f..6f62b36 100644
--- a/admin-ui/public/index.html
+++ b/admin-ui/public/index.html
@@ -21,7 +21,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
-
My app-45
+ My app-44
diff --git a/admin-ui/public/manifest.json b/admin-ui/public/manifest.json
index 9f673bd..971c951 100644
--- a/admin-ui/public/manifest.json
+++ b/admin-ui/public/manifest.json
@@ -1,6 +1,6 @@
{
- "short_name": "My app-45",
- "name": "My app-45",
+ "short_name": "My app-44",
+ "name": "My app-44",
"icons": [
{
"src": "favicon.ico",
diff --git a/admin-ui/src/App.tsx b/admin-ui/src/App.tsx
index f7a147e..80f4206 100644
--- a/admin-ui/src/App.tsx
+++ b/admin-ui/src/App.tsx
@@ -10,14 +10,6 @@ import { UserList } from "./user/UserList";
import { UserCreate } from "./user/UserCreate";
import { UserEdit } from "./user/UserEdit";
import { UserShow } from "./user/UserShow";
-import { CategoryList } from "./category/CategoryList";
-import { CategoryCreate } from "./category/CategoryCreate";
-import { CategoryEdit } from "./category/CategoryEdit";
-import { CategoryShow } from "./category/CategoryShow";
-import { ProductList } from "./product/ProductList";
-import { ProductCreate } from "./product/ProductCreate";
-import { ProductEdit } from "./product/ProductEdit";
-import { ProductShow } from "./product/ProductShow";
const App = (): React.ReactElement => {
const [dataProvider, setDataProvider] = useState(null);
@@ -36,7 +28,7 @@ const App = (): React.ReactElement => {
return (
{
create={UserCreate}
show={UserShow}
/>
-
-
);
diff --git a/admin-ui/src/Login.tsx b/admin-ui/src/Login.tsx
index 05025cf..5d2a002 100644
--- a/admin-ui/src/Login.tsx
+++ b/admin-ui/src/Login.tsx
@@ -29,7 +29,7 @@ const Login = ({ theme }: { theme?: object }) => {
src="https://amplication.com/assets/graphql.png"
alt="GraphQL API"
/>
- Connect via GrpahQL
+ Connect via GraphQL
Connect to the server using GraphQL API with a complete and
understandable description of the data in your API
diff --git a/admin-ui/src/api/user/User.ts b/admin-ui/src/api/user/User.ts
index 208e9d6..798058f 100644
--- a/admin-ui/src/api/user/User.ts
+++ b/admin-ui/src/api/user/User.ts
@@ -1,10 +1,8 @@
export type User = {
createdAt: Date;
- email: string | null;
firstName: string | null;
id: string;
lastName: string | null;
- mobile: string;
roles: Array
;
updatedAt: Date;
username: string;
diff --git a/admin-ui/src/api/user/UserCreateInput.ts b/admin-ui/src/api/user/UserCreateInput.ts
index 432fdf9..2348030 100644
--- a/admin-ui/src/api/user/UserCreateInput.ts
+++ b/admin-ui/src/api/user/UserCreateInput.ts
@@ -1,8 +1,6 @@
export type UserCreateInput = {
- email?: string | null;
firstName?: string | null;
lastName?: string | null;
- mobile: string;
password: string;
roles: Array;
username: string;
diff --git a/admin-ui/src/api/user/UserOrderByInput.ts b/admin-ui/src/api/user/UserOrderByInput.ts
index ed728eb..36cee1e 100644
--- a/admin-ui/src/api/user/UserOrderByInput.ts
+++ b/admin-ui/src/api/user/UserOrderByInput.ts
@@ -2,11 +2,9 @@ import { SortOrder } from "../../util/SortOrder";
export type UserOrderByInput = {
createdAt?: SortOrder;
- email?: SortOrder;
firstName?: SortOrder;
id?: SortOrder;
lastName?: SortOrder;
- mobile?: SortOrder;
password?: SortOrder;
roles?: SortOrder;
updatedAt?: SortOrder;
diff --git a/admin-ui/src/api/user/UserUpdateInput.ts b/admin-ui/src/api/user/UserUpdateInput.ts
index f98e894..2ec7caf 100644
--- a/admin-ui/src/api/user/UserUpdateInput.ts
+++ b/admin-ui/src/api/user/UserUpdateInput.ts
@@ -1,8 +1,6 @@
export type UserUpdateInput = {
- email?: string | null;
firstName?: string | null;
lastName?: string | null;
- mobile?: string;
password?: string;
roles?: Array;
username?: string;
diff --git a/admin-ui/src/api/user/UserWhereInput.ts b/admin-ui/src/api/user/UserWhereInput.ts
index 2624825..22c10cb 100644
--- a/admin-ui/src/api/user/UserWhereInput.ts
+++ b/admin-ui/src/api/user/UserWhereInput.ts
@@ -2,10 +2,8 @@ import { StringNullableFilter } from "../../util/StringNullableFilter";
import { StringFilter } from "../../util/StringFilter";
export type UserWhereInput = {
- email?: StringNullableFilter;
firstName?: StringNullableFilter;
id?: StringFilter;
lastName?: StringNullableFilter;
- mobile?: StringFilter;
username?: StringFilter;
};
diff --git a/admin-ui/src/user/UserCreate.tsx b/admin-ui/src/user/UserCreate.tsx
index 9fc4820..8dd276a 100644
--- a/admin-ui/src/user/UserCreate.tsx
+++ b/admin-ui/src/user/UserCreate.tsx
@@ -15,10 +15,8 @@ export const UserCreate = (props: CreateProps): React.ReactElement => {
return (
-
-
{
return (
-
-
{
>
-
-
diff --git a/admin-ui/src/user/UserShow.tsx b/admin-ui/src/user/UserShow.tsx
index cc46b5f..dea7fef 100644
--- a/admin-ui/src/user/UserShow.tsx
+++ b/admin-ui/src/user/UserShow.tsx
@@ -12,11 +12,9 @@ export const UserShow = (props: ListProps): React.ReactElement => {
-
-
diff --git a/ampconfig.json b/ampconfig.json
index 5bc5f88..ef48666 100644
--- a/ampconfig.json
+++ b/ampconfig.json
@@ -1,10 +1,10 @@
{
- "dataServiceGeneratorVersion": "0.6.1",
+ "dataServiceGeneratorVersion": "0.6.3",
"appInfo": {
- "name": "My app-45",
+ "name": "My app-44",
"description": "",
- "version": "qpq3cyhw",
- "id": "ckp253vyk4601151bs6mjio6mex",
- "url": "https://app.amplication.com/ckp253vyk4601151bs6mjio6mex"
+ "version": "wix8mghd",
+ "id": "ckp23p0dc4109371bs6z78utk4v",
+ "url": "https://app.amplication.com/ckp23p0dc4109371bs6z78utk4v"
}
}
diff --git a/server/package-lock.json b/server/package-lock.json
index 85c512e..342869f 100644
--- a/server/package-lock.json
+++ b/server/package-lock.json
@@ -1,10 +1,10 @@
{
- "name": "my-app-45-server",
+ "name": "my-app-44-server",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
- "name": "my-app-45-server",
+ "name": "my-app-44-server",
"dependencies": {
"@nestjs/common": "^7.3.2",
"@nestjs/config": "^0.6.1",
diff --git a/server/package.json b/server/package.json
index f8219c7..6bdb5f1 100644
--- a/server/package.json
+++ b/server/package.json
@@ -1,5 +1,5 @@
{
- "name": "my-app-45-server",
+ "name": "my-app-44-server",
"private": true,
"scripts": {
"start": "nest start",
diff --git a/server/prisma/schema.prisma b/server/prisma/schema.prisma
index be7f93a..669eb82 100644
--- a/server/prisma/schema.prisma
+++ b/server/prisma/schema.prisma
@@ -9,36 +9,11 @@ generator client {
model User {
createdAt DateTime @default(now())
- email String?
firstName String?
id String @id @default(cuid())
lastName String?
- mobile String
password String
roles String[]
updatedAt DateTime @updatedAt
username String @unique
-}
-
-model Category {
- categories Category @relation(name: "categories")
- createdAt DateTime @default(now())
- description String?
- id String @id @default(cuid())
- image String?
- parentId Category? @relation(name: "categories", fields: [parentIdId], references: [id])
- parentIdId String?
- tile String?
- updatedAt DateTime @updatedAt
-}
-
-model Product {
- categoryIds String?
- createdAt DateTime @default(now())
- id String @id @default(cuid())
- image String?
- name String?
- size String?
- sku String?
- updatedAt DateTime @updatedAt
}
\ No newline at end of file
diff --git a/server/scripts/seed.ts b/server/scripts/seed.ts
index 6c9b662..fbc67c4 100644
--- a/server/scripts/seed.ts
+++ b/server/scripts/seed.ts
@@ -28,7 +28,6 @@ async function seed(bcryptSalt: Salt) {
username: "admin",
password: await hash("admin", bcryptSalt),
roles: ["user"],
- mobile: "",
};
await client.user.upsert({
where: { username: data.username },
diff --git a/server/src/app.module.ts b/server/src/app.module.ts
index f0f1f50..544acfa 100644
--- a/server/src/app.module.ts
+++ b/server/src/app.module.ts
@@ -1,7 +1,5 @@
import { Module } from "@nestjs/common";
import { UserModule } from "./user/user.module";
-import { CategoryModule } from "./category/category.module";
-import { ProductModule } from "./product/product.module";
import { ACLModule } from "./auth/acl.module";
import { AuthModule } from "./auth/auth.module";
import { MorganModule } from "nest-morgan";
@@ -14,8 +12,6 @@ import { GraphQLModule } from "@nestjs/graphql";
controllers: [],
imports: [
UserModule,
- CategoryModule,
- ProductModule,
ACLModule,
AuthModule,
MorganModule,
diff --git a/server/src/auth/auth.resolver.ts b/server/src/auth/auth.resolver.ts
index 05b3a0b..cc752d9 100644
--- a/server/src/auth/auth.resolver.ts
+++ b/server/src/auth/auth.resolver.ts
@@ -1,8 +1,12 @@
-import { Args, Mutation, Resolver } from "@nestjs/graphql";
+import * as common from "@nestjs/common";
+import * as gqlBasicAuthGuard from "../auth/gqlBasicAuth.guard";
+import * as gqlACGuard from "../auth/gqlAC.guard";
+import { Args, Mutation, Resolver, Query } from "@nestjs/graphql";
import { ApolloError } from "apollo-server-express";
import { AuthService } from "./auth.service";
import { UserInfo } from "./UserInfo";
import { LoginArgs } from "./LoginArgs";
+import { UserData } from "./gqlUserData.decorator";
@Resolver(UserInfo)
export class AuthResolver {
@@ -18,4 +22,10 @@ export class AuthResolver {
}
return user;
}
+
+ @Query(() => UserInfo)
+ @common.UseGuards(gqlBasicAuthGuard.GqlBasicAuthGuard, gqlACGuard.GqlACGuard)
+ async userInfo(@UserData() userInfo: UserInfo): Promise {
+ return userInfo;
+ }
}
diff --git a/server/src/auth/gqlUserData.decorator.ts b/server/src/auth/gqlUserData.decorator.ts
new file mode 100644
index 0000000..4871099
--- /dev/null
+++ b/server/src/auth/gqlUserData.decorator.ts
@@ -0,0 +1,15 @@
+import { createParamDecorator, ExecutionContext } from "@nestjs/common";
+import { GqlExecutionContext } from "@nestjs/graphql";
+import { UserInfo } from "./UserInfo";
+
+/**
+ * Access the user data from the request object i.e `req.user`.
+ */
+export function getUser(executionContext: ExecutionContext): UserInfo {
+ const gqlExecutionContext = GqlExecutionContext.create(executionContext);
+ return gqlExecutionContext.getContext().req.user;
+}
+
+export const UserData = createParamDecorator((data, ctx: ExecutionContext) =>
+ getUser(ctx)
+);
diff --git a/server/src/grants.json b/server/src/grants.json
index 4d33df4..55c1942 100644
--- a/server/src/grants.json
+++ b/server/src/grants.json
@@ -28,65 +28,5 @@
"resource": "User",
"action": "read:any",
"attributes": "*"
- },
- {
- "role": "user",
- "resource": "Category",
- "action": "read:own",
- "attributes": "*"
- },
- {
- "role": "user",
- "resource": "Category",
- "action": "create:any",
- "attributes": "*"
- },
- {
- "role": "user",
- "resource": "Category",
- "action": "update:any",
- "attributes": "*"
- },
- {
- "role": "user",
- "resource": "Category",
- "action": "delete:any",
- "attributes": "*"
- },
- {
- "role": "user",
- "resource": "Category",
- "action": "read:any",
- "attributes": "*"
- },
- {
- "role": "user",
- "resource": "Product",
- "action": "read:own",
- "attributes": "*"
- },
- {
- "role": "user",
- "resource": "Product",
- "action": "create:any",
- "attributes": "*"
- },
- {
- "role": "user",
- "resource": "Product",
- "action": "update:any",
- "attributes": "*"
- },
- {
- "role": "user",
- "resource": "Product",
- "action": "delete:any",
- "attributes": "*"
- },
- {
- "role": "user",
- "resource": "Product",
- "action": "read:any",
- "attributes": "*"
}
]
\ No newline at end of file
diff --git a/server/src/swagger.ts b/server/src/swagger.ts
index ded984b..73986a5 100644
--- a/server/src/swagger.ts
+++ b/server/src/swagger.ts
@@ -3,11 +3,11 @@ import { DocumentBuilder } from "@nestjs/swagger";
export const swaggerPath = "api";
export const swaggerDocumentOptions = new DocumentBuilder()
- .setTitle("My app-45")
+ .setTitle("My app-44")
.setDescription(
'\n\n## Congratulations! Your application is ready.\n\nPlease note that all endpoints are secured with HTTP basic authentication.\nBy default, your app comes with one user with the username "admin" and password "admin".\nLearn more in [our docs](https://docs.amplication.com)'
)
- .setVersion("qpq3cyhw")
+ .setVersion("wix8mghd")
.addBasicAuth()
.build();
@@ -17,5 +17,5 @@ export const swaggerSetupOptions = {
},
customCssUrl: "../swagger/swagger.css",
customfavIcon: "../swagger/favicon.png",
- customSiteTitle: "My app-45",
+ customSiteTitle: "My app-44",
};
diff --git a/server/src/user/base/User.ts b/server/src/user/base/User.ts
index 65f783c..e3a5af3 100644
--- a/server/src/user/base/User.ts
+++ b/server/src/user/base/User.ts
@@ -12,17 +12,6 @@ class User {
@Field(() => Date)
createdAt!: Date;
- @ApiProperty({
- required: false,
- type: String,
- })
- @IsString()
- @IsOptional()
- @Field(() => String, {
- nullable: true,
- })
- email!: string | null;
-
@ApiProperty({
required: false,
type: String,
@@ -53,14 +42,6 @@ class User {
})
lastName!: string | null;
- @ApiProperty({
- required: true,
- type: String,
- })
- @IsString()
- @Field(() => String)
- mobile!: string;
-
@ApiProperty({
required: true,
type: [String],
diff --git a/server/src/user/base/UserCreateInput.ts b/server/src/user/base/UserCreateInput.ts
index ae5d745..6e217e9 100644
--- a/server/src/user/base/UserCreateInput.ts
+++ b/server/src/user/base/UserCreateInput.ts
@@ -3,17 +3,6 @@ import { ApiProperty } from "@nestjs/swagger";
import { IsString, IsOptional } from "class-validator";
@InputType()
class UserCreateInput {
- @ApiProperty({
- required: false,
- type: String,
- })
- @IsString()
- @IsOptional()
- @Field(() => String, {
- nullable: true,
- })
- email?: string | null;
-
@ApiProperty({
required: false,
type: String,
@@ -36,14 +25,6 @@ class UserCreateInput {
})
lastName?: string | null;
- @ApiProperty({
- required: true,
- type: String,
- })
- @IsString()
- @Field(() => String)
- mobile!: string;
-
@ApiProperty({
required: true,
type: String,
diff --git a/server/src/user/base/UserOrderByInput.ts b/server/src/user/base/UserOrderByInput.ts
index 6261184..5bc72a2 100644
--- a/server/src/user/base/UserOrderByInput.ts
+++ b/server/src/user/base/UserOrderByInput.ts
@@ -16,15 +16,6 @@ class UserOrderByInput {
})
createdAt?: SortOrder;
- @ApiProperty({
- required: false,
- enum: ["Asc", "Desc"],
- })
- @Field(() => SortOrder, {
- nullable: true,
- })
- email?: SortOrder;
-
@ApiProperty({
required: false,
enum: ["Asc", "Desc"],
@@ -52,15 +43,6 @@ class UserOrderByInput {
})
lastName?: SortOrder;
- @ApiProperty({
- required: false,
- enum: ["Asc", "Desc"],
- })
- @Field(() => SortOrder, {
- nullable: true,
- })
- mobile?: SortOrder;
-
@ApiProperty({
required: false,
enum: ["Asc", "Desc"],
diff --git a/server/src/user/base/UserUpdateInput.ts b/server/src/user/base/UserUpdateInput.ts
index 3d83a6a..39cfa90 100644
--- a/server/src/user/base/UserUpdateInput.ts
+++ b/server/src/user/base/UserUpdateInput.ts
@@ -3,17 +3,6 @@ import { ApiProperty } from "@nestjs/swagger";
import { IsString, IsOptional } from "class-validator";
@InputType()
class UserUpdateInput {
- @ApiProperty({
- required: false,
- type: String,
- })
- @IsString()
- @IsOptional()
- @Field(() => String, {
- nullable: true,
- })
- email?: string | null;
-
@ApiProperty({
required: false,
type: String,
@@ -36,17 +25,6 @@ class UserUpdateInput {
})
lastName?: string | null;
- @ApiProperty({
- required: false,
- type: String,
- })
- @IsString()
- @IsOptional()
- @Field(() => String, {
- nullable: true,
- })
- mobile?: string;
-
@ApiProperty({
required: false,
type: String,
diff --git a/server/src/user/base/UserWhereInput.ts b/server/src/user/base/UserWhereInput.ts
index 98820e7..8477a7f 100644
--- a/server/src/user/base/UserWhereInput.ts
+++ b/server/src/user/base/UserWhereInput.ts
@@ -6,17 +6,6 @@ import { IsOptional } from "class-validator";
import { StringFilter } from "../../util/StringFilter";
@InputType()
class UserWhereInput {
- @ApiProperty({
- required: false,
- type: StringNullableFilter,
- })
- @Type(() => StringNullableFilter)
- @IsOptional()
- @Field(() => StringNullableFilter, {
- nullable: true,
- })
- email?: StringNullableFilter;
-
@ApiProperty({
required: false,
type: StringNullableFilter,
@@ -50,17 +39,6 @@ class UserWhereInput {
})
lastName?: StringNullableFilter;
- @ApiProperty({
- required: false,
- type: StringFilter,
- })
- @Type(() => StringFilter)
- @IsOptional()
- @Field(() => StringFilter, {
- nullable: true,
- })
- mobile?: StringFilter;
-
@ApiProperty({
required: false,
type: StringFilter,
diff --git a/server/src/user/base/user.controller.base.spec.ts b/server/src/user/base/user.controller.base.spec.ts
index a1af5bf..ee70bfb 100644
--- a/server/src/user/base/user.controller.base.spec.ts
+++ b/server/src/user/base/user.controller.base.spec.ts
@@ -12,11 +12,9 @@ const nonExistingId = "nonExistingId";
const existingId = "existingId";
const CREATE_INPUT = {
createdAt: new Date(),
- email: "exampleEmail",
firstName: "exampleFirstName",
id: "exampleId",
lastName: "exampleLastName",
- mobile: "exampleMobile",
password: "examplePassword",
roles: ["exampleRoles"],
updatedAt: new Date(),
@@ -24,11 +22,9 @@ const CREATE_INPUT = {
};
const CREATE_RESULT = {
createdAt: new Date(),
- email: "exampleEmail",
firstName: "exampleFirstName",
id: "exampleId",
lastName: "exampleLastName",
- mobile: "exampleMobile",
password: "examplePassword",
roles: ["exampleRoles"],
updatedAt: new Date(),
@@ -37,11 +33,9 @@ const CREATE_RESULT = {
const FIND_MANY_RESULT = [
{
createdAt: new Date(),
- email: "exampleEmail",
firstName: "exampleFirstName",
id: "exampleId",
lastName: "exampleLastName",
- mobile: "exampleMobile",
password: "examplePassword",
roles: ["exampleRoles"],
updatedAt: new Date(),
@@ -50,11 +44,9 @@ const FIND_MANY_RESULT = [
];
const FIND_ONE_RESULT = {
createdAt: new Date(),
- email: "exampleEmail",
firstName: "exampleFirstName",
id: "exampleId",
lastName: "exampleLastName",
- mobile: "exampleMobile",
password: "examplePassword",
roles: ["exampleRoles"],
updatedAt: new Date(),
diff --git a/server/src/user/base/user.controller.base.ts b/server/src/user/base/user.controller.base.ts
index 89e8726..9cc97ff 100644
--- a/server/src/user/base/user.controller.base.ts
+++ b/server/src/user/base/user.controller.base.ts
@@ -58,11 +58,9 @@ export class UserControllerBase {
data: data,
select: {
createdAt: true,
- email: true,
firstName: true,
id: true,
lastName: true,
- mobile: true,
roles: true,
updatedAt: true,
username: true,
@@ -101,11 +99,9 @@ export class UserControllerBase {
...args,
select: {
createdAt: true,
- email: true,
firstName: true,
id: true,
lastName: true,
- mobile: true,
roles: true,
updatedAt: true,
username: true,
@@ -139,11 +135,9 @@ export class UserControllerBase {
where: params,
select: {
createdAt: true,
- email: true,
firstName: true,
id: true,
lastName: true,
- mobile: true,
roles: true,
updatedAt: true,
username: true,
@@ -198,11 +192,9 @@ export class UserControllerBase {
data: data,
select: {
createdAt: true,
- email: true,
firstName: true,
id: true,
lastName: true,
- mobile: true,
roles: true,
updatedAt: true,
username: true,
@@ -237,11 +229,9 @@ export class UserControllerBase {
where: params,
select: {
createdAt: true,
- email: true,
firstName: true,
id: true,
lastName: true,
- mobile: true,
roles: true,
updatedAt: true,
username: true,