-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
707 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "localFiles" ADD COLUMN "optimized" BOOLEAN NOT NULL DEFAULT false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Warnings: | ||
- Added the required column `ownerId` to the `localFiles` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "localFiles" ADD COLUMN "ownerId" TEXT NOT NULL, | ||
ADD COLUMN "size" INTEGER; | ||
|
||
-- CreateTable | ||
CREATE TABLE "owners" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT, | ||
"email" TEXT, | ||
"externalId" TEXT NOT NULL, | ||
"domain" TEXT NOT NULL, | ||
"password" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "owners_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "owners_externalId_domain_key" ON "owners"("externalId", "domain"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "localFiles" ADD CONSTRAINT "localFiles_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "owners"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import generator from 'generate-password-ts'; | ||
import * as bcrypt from 'bcrypt'; | ||
|
||
@Injectable() | ||
export class AuthService { | ||
/** | ||
* Generates a password | ||
*/ | ||
async generateAPassword() { | ||
const password = generator.generate({ | ||
length: 30, | ||
numbers: true, | ||
symbols: true, | ||
}); | ||
|
||
const saltOrRounds = 15; | ||
return await bcrypt.hash(password, saltOrRounds); | ||
} | ||
|
||
/** | ||
* Compares a password with a hash | ||
* @param password | ||
* @param hash | ||
*/ | ||
async comparePassword(password: string, hash: string) { | ||
return await bcrypt.compare(password, hash); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class LocalFileFilterDto { | ||
@ApiProperty({ | ||
description: 'Type of file', | ||
enum: ['local', 'avatar'], | ||
required: false, | ||
}) | ||
type?: string; | ||
@ApiProperty({ | ||
description: 'Tags of the file', | ||
required: false, | ||
}) | ||
tags?: string[]; | ||
@ApiProperty({ | ||
description: 'Description of the file', | ||
required: false, | ||
}) | ||
description?: string; | ||
@ApiProperty({ | ||
description: 'Filename of the file', | ||
required: false, | ||
}) | ||
filename?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.