-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OV-2: FEAT: Sign-in flow #17
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f9f85c8
OV-2: + add sign in string to AuthApiPath const
JKaypa 532a119
OV-2: + create user signin request dto type
JKaypa 8e9d770
OV-2: + create user signin response dto type
JKaypa 55df57e
OV-2: + add 400 error code
JKaypa 6df4a10
OV-2: * edit props order
JKaypa 782952a
OV-2: + add validation message
JKaypa 830ec5a
OV-2: * edit service, repository find method type
JKaypa f07f147
OV-2: * update repository find method
JKaypa 1f7ec60
OV-2: * update service find method
JKaypa 483f1c8
OV-2: + implement sign in service method
JKaypa 4c449b6
OV-2: + add sign in endpoint to auth controller
JKaypa c32e1fa
OV-2: + import user validation messages
JKaypa 1beb23a
OV-2: + import sign in dto types
JKaypa 9139197
OV-2: + implement validation
JKaypa 375fde5
OV-2: * update imports from users/users
JKaypa d5f4f15
OV-2: * edit findByEmail methods
JKaypa 7f48764
OV-2: - remove unnecessary types
JKaypa 06fa5d1
OV-2: - * fix service types
JKaypa e411fe2
OV-2: + implemented swagger and added sign-in docs
JKaypa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 +1 @@ | ||
export { AuthApiPath } from 'shared'; | ||
export { AuthApiPath, UserValidationMessage } from 'shared'; |
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,7 @@ | ||
export { | ||
type UserGetAllResponseDto, | ||
type UserSignInRequestDto, | ||
type UserSignInResponseDto, | ||
type UserSignUpRequestDto, | ||
type UserSignUpResponseDto, | ||
} from 'shared'; |
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
2 changes: 1 addition & 1 deletion
2
backend/src/bundles/users/validation-schemas/validation-schemas.ts
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 +1 @@ | ||
export { userSignUpValidationSchema } from 'shared'; | ||
export { userSignInValidationSchema, userSignUpValidationSchema } from 'shared'; |
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,6 @@ | ||
const AuthApiPath = { | ||
ROOT: '/', | ||
SIGN_IN: '/sign-in', | ||
SIGN_UP: '/sign-up', | ||
} as const; | ||
|
||
|
5 changes: 5 additions & 0 deletions
5
shared/src/bundles/users/enums/user-validation-message.enum.ts
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,6 +1,11 @@ | ||
const UserValidationMessage = { | ||
EMAIL_REQUIRE: 'Email is required', | ||
EMAIL_WRONG: 'Email is wrong', | ||
EMAIL_INVALID: 'Please enter a valid email', | ||
FIELD_REQUIRE: 'Please fill out this field', | ||
PASSWORD_LENGTH: 'Password must have from 6 to 12 characters', | ||
INVALID_DATA: 'Incorrect email or password. Please try again.', | ||
WRONG_CREDENTIALS: 'Email or password are incorrect', | ||
} as const; | ||
|
||
export { UserValidationMessage }; |
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,8 @@ | ||
const UserValidationRule = { | ||
EMAIL_MINIMUM_LENGTH: 1, | ||
EMAIL_MINIMUM_LENGTH: 6, | ||
EMAIL_MAXIMUM_LENGTH: 320, | ||
PASSWORD_MINIMUM_LENGTH: 6, | ||
PASSWORD_MAXIMUM_LENGTH: 12, | ||
} as const; | ||
|
||
export { UserValidationRule }; |
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,4 +1,6 @@ | ||
export { type UserGetAllItemResponseDto } from './user-get-all-item-response-dto.type.js'; | ||
export { type UserGetAllResponseDto } from './user-get-all-response-dto.type.js'; | ||
export { type UserSignInRequestDto } from './user-sign-in-request-dto.type.js'; | ||
export { type UserSignInResponseDto } from './user-sign-in-response-dto.type.js'; | ||
export { type UserSignUpRequestDto } from './user-sign-up-request-dto.type.js'; | ||
export { type UserSignUpResponseDto } from './user-sign-up-response-dto.type.js'; |
5 changes: 5 additions & 0 deletions
5
shared/src/bundles/users/types/user-sign-in-request-dto.type.ts
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,5 @@ | ||
import { type UserSignUpRequestDto } from './types.js'; | ||
|
||
type UserSignInRequestDto = Pick<UserSignUpRequestDto, 'email' | 'password'>; | ||
|
||
export { type UserSignInRequestDto }; |
5 changes: 5 additions & 0 deletions
5
shared/src/bundles/users/types/user-sign-in-response-dto.type.ts
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,5 @@ | ||
import { type UserSignUpResponseDto } from './user-sign-up-response-dto.type.js'; | ||
|
||
type UserSignInResponseDto = UserSignUpResponseDto; | ||
|
||
export { type UserSignInResponseDto }; |
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
36 changes: 36 additions & 0 deletions
36
shared/src/bundles/users/validation-schemas/user-sig-in.validation-schema.ts
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,36 @@ | ||
import { z } from 'zod'; | ||
|
||
import { UserValidationMessage, UserValidationRule } from '../enums/enums.js'; | ||
|
||
type UserSignInRequestValidationDto = { | ||
email: z.ZodString; | ||
password: z.ZodString; | ||
}; | ||
|
||
const userSignIn = z | ||
.object<UserSignInRequestValidationDto>({ | ||
email: z | ||
.string({ required_error: UserValidationMessage.FIELD_REQUIRE }) | ||
.trim() | ||
.min(UserValidationRule.EMAIL_MINIMUM_LENGTH, { | ||
message: UserValidationMessage.EMAIL_INVALID, | ||
}) | ||
.max(UserValidationRule.EMAIL_MAXIMUM_LENGTH, { | ||
message: UserValidationMessage.EMAIL_INVALID, | ||
}) | ||
.email({ | ||
message: UserValidationMessage.EMAIL_INVALID, | ||
}), | ||
password: z | ||
.string({ required_error: UserValidationMessage.FIELD_REQUIRE }) | ||
.trim() | ||
.min(UserValidationRule.PASSWORD_MINIMUM_LENGTH, { | ||
message: UserValidationMessage.PASSWORD_LENGTH, | ||
}) | ||
.max(UserValidationRule.PASSWORD_MAXIMUM_LENGTH, { | ||
message: UserValidationMessage.PASSWORD_LENGTH, | ||
}), | ||
}) | ||
.required(); | ||
|
||
export { userSignIn }; |
1 change: 1 addition & 0 deletions
1
shared/src/bundles/users/validation-schemas/validation-schemas.ts
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 +1,2 @@ | ||
export { userSignIn } from './user-sig-in.validation-schema.js'; | ||
export { userSignUp } from './user-sign-up.validation-schema.js'; |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should add js doc for endpoint