-
Notifications
You must be signed in to change notification settings - Fork 8
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
Allow using username
and email
in SMTP configuration
#3398
Merged
Merged
Changes from 14 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
cd7e4e4
Remove isDiscourse check and apply adding email or username for all a…
samaradel 6f50303
Update packages/playground/src/components/smtp_server.vue
samaradel f994a54
Update packages/playground/src/weblets/tf_discourse.vue
samaradel b7a7836
Validate SMTP username/email
samaradel 81af97c
Fix build
samaradel bc4c149
Apply code scanning fix for overly permissive regular expression range
samaradel 4c1c955
Update packages/playground/src/utils/validators.ts
samaradel f2e0fc8
rn validate smtp function
samaradel f3bbf8d
Rename validate function parameter
samaradel a05eb55
Add doc string for validate smtp function
samaradel 0674977
- Set validation to limit username
samaradel 788077b
- Add min length and max length for the username and Email
samaradel 0d6a1b3
Add doc string for IsAlphaExpectDashAndUnderscore validator
samaradel 9fb6875
Add unit test for IsAlphaExpectDashAndUnderscore function
samaradel 4ad30a6
Update SMTP input validation msg
samaradel 51465dc
Update SMTP input validation msg
samaradel b9ff25e
Remove number validator of first char and add test case for it
samaradel 17e8dba
Modify the valitator function to accept numbers too
samaradel 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,17 +20,23 @@ | |
<input-validator | ||
:value="$props.modelValue.username" | ||
:rules="[ | ||
validators.required('Email is required.'), | ||
validators.isEmail('Please provide a valid email address.'), | ||
v => { | ||
return isDiscourse ? undefined : validators.isEmail('Please provide a valid email address.')(v); | ||
validators.required('Email or Username is required.'), | ||
validators.minLength('Username must be at least 2 characters.', 2), | ||
validators.maxLength('Username must be at least 50 characters.', 50), | ||
(v: string) => { | ||
return ( | ||
validators.isEmail('Please provide a valid email address.')(v) && | ||
(validators.IsAlphaExpectDashAndUnderscore( | ||
'Username should consist of letters, dashs and underscores only.' | ||
)(v) || validators.isAlpha('Username must start with an alphabetical character.')(v[0])) | ||
); | ||
}, | ||
]" | ||
#="{ props }" | ||
> | ||
<input-tooltip :tooltip="isDiscourse ? 'SMTP admin email, Username or API key.' : 'SMTP admin email'"> | ||
<input-tooltip tooltip="SMTP admin email, Username or API key."> | ||
<v-text-field | ||
label="Admin Email" | ||
label="Admin Email or Username" | ||
placeholder="[email protected]" | ||
v-model="$props.modelValue.username" | ||
v-bind="props" | ||
|
@@ -46,7 +52,7 @@ | |
:rules="[ | ||
validators.required('Password is required.'), | ||
validators.minLength('Password must be at least 6 characters.', 6), | ||
validators.maxLength('Password cannot exceed 50 characters.', 50), | ||
validators.maxLength('Password cannot exceed 69 characters.', 69), | ||
samaradel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
validators.pattern('Password should not contain whitespaces.', { | ||
pattern: /^[^\s]+$/, | ||
}), | ||
|
@@ -139,7 +145,6 @@ defineProps<{ | |
tls?: boolean; | ||
email?: boolean; | ||
persistent?: boolean; | ||
isDiscourse?: boolean; | ||
}>(); | ||
</script> | ||
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add unit tests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
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
38 changes: 38 additions & 0 deletions
38
packages/playground/tests/utils/validators/IsAlphaExpectDashAndUnderscore.test.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,38 @@ | ||
import { describe, expect, it } from "vitest"; | ||
|
||
import { IsAlphaExpectDashAndUnderscore } from "../../../src/utils/validators"; | ||
|
||
const validator = IsAlphaExpectDashAndUnderscore("Username should consist of letters, dashs and underscores only."); | ||
|
||
describe("IsAlphaExpectDashAndUnderscore", () => { | ||
it("returns an error message for input with spaces", () => { | ||
const result = validator("hello world!"); | ||
expect(result).toEqual({ | ||
message: "Username should consist of letters, dashs and underscores only.", | ||
requiredTrue: true, | ||
}); | ||
}); | ||
|
||
it("returns an error message for input with special characters", () => { | ||
const result = validator("hello@world"); | ||
expect(result).toEqual({ | ||
message: "Username should consist of letters, dashs and underscores only.", | ||
requiredTrue: true, | ||
}); | ||
}); | ||
|
||
it("returns undefined for valid username that contains underscore", () => { | ||
const result = validator("hello_world"); | ||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
it("returns undefined for valid username that contains dash", () => { | ||
const result = validator("hello-world"); | ||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
it("returns undefined for valid username", () => { | ||
const result = validator("hello"); | ||
expect(result).toBeUndefined(); | ||
}); | ||
}); |
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.
we shouldn't use the
at least
on max lengthThere 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.
also is this validation on user name only? what if the email exceeds the 50 char ? the length validation message will appear
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.
done