mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
refactor(core): guard phone number with digital-only regex (#744)
This commit is contained in:
parent
5909727ebc
commit
6ac70c5eb7
3 changed files with 6 additions and 6 deletions
|
@ -1,3 +1,3 @@
|
|||
// TODO - LOG-1876: Share Regex Between Logto Core and Front-End
|
||||
export const emailRegEx = /^\S+@\S+\.\S+$/;
|
||||
export const phoneRegEx = /^[1-9]\d{10}$/;
|
||||
export const phoneRegEx = /^\d+$/;
|
||||
|
|
|
@ -556,10 +556,10 @@ describe('sessionRoutes', () => {
|
|||
expect(response.statusCode).toEqual(400);
|
||||
});
|
||||
|
||||
it('throw error if phone not valid (not exactly 11-digits)', async () => {
|
||||
it('throw error if phone not valid (without digits)', async () => {
|
||||
const response = await sessionRequest
|
||||
.post('/session/register/passwordless/sms/send-passcode')
|
||||
.send({ phone: '1300000000' });
|
||||
.send({ phone: 'abcdefg' });
|
||||
expect(response.statusCode).toEqual(400);
|
||||
});
|
||||
|
||||
|
@ -596,10 +596,10 @@ describe('sessionRoutes', () => {
|
|||
expect(response.statusCode).toEqual(400);
|
||||
});
|
||||
|
||||
it('throw error if phone not valid (not exactly 11-digits)', async () => {
|
||||
it('throw error if phone not valid (without digits)', async () => {
|
||||
const response = await sessionRequest
|
||||
.post('/session/register/passwordless/sms/verify-passcode')
|
||||
.send({ phone: '1300000000', code: '1234' });
|
||||
.send({ phone: 'abcdefg', code: '1234' });
|
||||
expect(response.statusCode).toEqual(400);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export const emailRegEx = /^\S+@\S+\.\S+$/;
|
||||
export const phoneRegEx = /^[1-9]\d{10}$/;
|
||||
export const phoneRegEx = /^\d+$/;
|
||||
export const usernameRegEx = /^.{3,}$/;
|
||||
export const nameRegEx = /^.{3,}$/;
|
||||
export const passwordRegEx = /^.{6,}$/;
|
||||
|
|
Loading…
Reference in a new issue