-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add joined at date for searched user * Update user search query to respect respect http standards * Enable cors * minor fixes * Correct relations * Check if users are connected when doing an user search * fix db structure * fix namings * Use passwordless signup * Return props needed for signin redirection
- Loading branch information
1 parent
2b4edfb
commit f128c7f
Showing
7 changed files
with
24 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,39 +39,23 @@ describe('Auth Controller Tests', () => { | |
expect(prisma).toBeDefined(); | ||
}); | ||
|
||
it('should fail sign up if password does not meet requirements', async () => { | ||
const response = await app.inject({ | ||
method: 'POST', | ||
url: '/auth/sign-up', | ||
payload: { | ||
email: '[email protected]', | ||
password: 'password', | ||
}, | ||
}); | ||
|
||
expect(response.statusCode).toEqual(400); | ||
}); | ||
|
||
it('should be able to sign up using email and password', async () => { | ||
it('should be able to sign up using email', async () => { | ||
const response = await app.inject({ | ||
method: 'POST', | ||
url: '/auth/sign-up', | ||
payload: { | ||
email: '[email protected]', | ||
password: 'Password123', | ||
}, | ||
}); | ||
|
||
expect(response.statusCode).toEqual(201); | ||
expect(response.json().email).toEqual('[email protected]'); | ||
expect(response.json().password).toBeUndefined(); | ||
}); | ||
|
||
it('should be able to sign in using email and password', async () => { | ||
it('should be able to sign in using email', async () => { | ||
await prisma.user.create({ | ||
data: { | ||
email: '[email protected]', | ||
password: SHA256('password').toString(), | ||
isEmailVerified: true, | ||
authType: AuthType.EMAIL, | ||
}, | ||
|
@@ -82,14 +66,11 @@ describe('Auth Controller Tests', () => { | |
url: '/auth/sign-in', | ||
payload: { | ||
email: '[email protected]', | ||
password: 'password', | ||
}, | ||
}); | ||
|
||
expect(response.statusCode).toEqual(201); | ||
expect(response.json().email).toEqual('[email protected]'); | ||
expect(response.json().password).toBeUndefined(); | ||
expect(response.json().token).toBeDefined(); | ||
}); | ||
|
||
it('should send verification code to email on sign up', async () => { | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsEmail, IsString } from 'class-validator'; | ||
import { IsEmail } from 'class-validator'; | ||
|
||
export class SigninDto { | ||
@IsEmail() | ||
|
@@ -11,13 +11,4 @@ export class SigninDto { | |
example: '[email protected]', | ||
}) | ||
email: string; | ||
@IsString() | ||
@ApiProperty({ | ||
name: 'password', | ||
description: 'User password. Must be a string.', | ||
required: true, | ||
type: String, | ||
example: 'password123', | ||
}) | ||
password: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsEmail, Matches } from 'class-validator'; | ||
import { IsEmail } from 'class-validator'; | ||
|
||
export class SignupDto { | ||
@IsEmail() | ||
|
@@ -11,17 +11,4 @@ export class SignupDto { | |
example: '[email protected]', | ||
}) | ||
email: string; | ||
@Matches(/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{9,}$/, { | ||
message: | ||
'Password must contain at least 1 letter, 1 number and be at least 9 characters long', | ||
}) | ||
@ApiProperty({ | ||
name: 'password', | ||
description: | ||
'User password. Must contain at least 1 letter, 1 number and be at least 9 characters long.', | ||
required: true, | ||
type: String, | ||
example: 'password123', | ||
}) | ||
password: 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
8 changes: 8 additions & 0 deletions
8
src/prisma/migrations/20240509140026_drop_password/migration.sql
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,8 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `password` on the `User` table. All the data in the column will be lost. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "User" DROP COLUMN "password"; |
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