aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNassim Bounouas <NassimBounouas@users.noreply.github.com>2019-07-02 11:16:33 +0200
committerChocobozzz <me@florianbigard.com>2019-07-02 11:16:33 +0200
commit50b4dcce56275e57fc15ade7529f5c501cad150d (patch)
treee46c0faa68eb92f964dad01df83b0126a7e9077e
parentc1109b45f6d6ed8024908df2340f8c06ae4c5db7 (diff)
downloadPeerTube-50b4dcce56275e57fc15ade7529f5c501cad150d.tar.gz
PeerTube-50b4dcce56275e57fc15ade7529f5c501cad150d.tar.zst
PeerTube-50b4dcce56275e57fc15ade7529f5c501cad150d.zip
Fix/connection with email (#1917)
* #1916 Load user by email - insensitive query * Revert "Case insensitive login" This reverts commit c1521ca3d757bee91f7dfbb15b3717162bf4997d. * #1916 Load user - insensitive query for username and sensitive for email * #1916 Unit test for insensitive username login && documentation
-rw-r--r--.github/CONTRIBUTING.md4
-rw-r--r--client/src/app/core/auth/auth.service.ts2
-rw-r--r--server/models/account/user.ts6
-rw-r--r--server/tests/api/users/users.ts11
4 files changed, 17 insertions, 6 deletions
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index bbf06c87f..1672ebfa9 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -181,13 +181,13 @@ Then, we can create the databases (if they don't already exist):
181 181
182``` 182```
183$ sudo -u postgres createuser you_username --createdb --superuser 183$ sudo -u postgres createuser you_username --createdb --superuser
184$ createdb -O peertube peertube_test{1,2,3,4,5,6} 184$ npm run clean:server:test
185``` 185```
186 186
187Build the application and run the unit/integration tests: 187Build the application and run the unit/integration tests:
188 188
189``` 189```
190$ npm run build 190$ npm run build -- --light
191$ npm test 191$ npm test
192``` 192```
193 193
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index 4fc04a05c..eaa822e0f 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -153,7 +153,7 @@ export class AuthService {
153 response_type: 'code', 153 response_type: 'code',
154 grant_type: 'password', 154 grant_type: 'password',
155 scope: 'upload', 155 scope: 'upload',
156 username: username.toLowerCase(), 156 username,
157 password 157 password
158 } 158 }
159 159
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index aac691d66..0f425bb82 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -367,7 +367,7 @@ export class UserModel extends Model<UserModel> {
367 static loadByUsername (username: string) { 367 static loadByUsername (username: string) {
368 const query = { 368 const query = {
369 where: { 369 where: {
370 username 370 username: { [ Op.iLike ]: username }
371 } 371 }
372 } 372 }
373 373
@@ -377,7 +377,7 @@ export class UserModel extends Model<UserModel> {
377 static loadByUsernameAndPopulateChannels (username: string) { 377 static loadByUsernameAndPopulateChannels (username: string) {
378 const query = { 378 const query = {
379 where: { 379 where: {
380 username 380 username: { [ Op.iLike ]: username }
381 } 381 }
382 } 382 }
383 383
@@ -399,7 +399,7 @@ export class UserModel extends Model<UserModel> {
399 399
400 const query = { 400 const query = {
401 where: { 401 where: {
402 [ Op.or ]: [ { username }, { email } ] 402 [ Op.or ]: [ { username: { [ Op.iLike ]: username } }, { email } ]
403 } 403 }
404 } 404 }
405 405
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 403d1a089..6fc2a070f 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -116,6 +116,17 @@ describe('Test users', function () {
116 116
117 accessToken = res.body.access_token 117 accessToken = res.body.access_token
118 }) 118 })
119
120 it('Should be able to login with an insensitive username', async function () {
121 const user = { username: 'RoOt', password: server.user.password }
122 const res = await login(server.url, server.client, user, 200)
123
124 const user2 = { username: 'rOoT', password: server.user.password }
125 const res2 = await login(server.url, server.client, user2, 200)
126
127 const user3 = { username: 'ROOt', password: server.user.password }
128 const res3 = await login(server.url, server.client, user3, 200)
129 })
119 }) 130 })
120 131
121 describe('Upload', function () { 132 describe('Upload', function () {