mirror of https://github.com/Chocobozzz/PeerTube
Fix/connection with email (#1917)
* #1916 Load user by email - insensitive query
* Revert "Case insensitive login"
This reverts commit c1521ca3d7
.
* #1916 Load user - insensitive query for username and sensitive for email
* #1916 Unit test for insensitive username login && documentation
pull/1958/head
parent
c1109b45f6
commit
50b4dcce56
|
@ -181,13 +181,13 @@ Then, we can create the databases (if they don't already exist):
|
||||||
|
|
||||||
```
|
```
|
||||||
$ sudo -u postgres createuser you_username --createdb --superuser
|
$ sudo -u postgres createuser you_username --createdb --superuser
|
||||||
$ createdb -O peertube peertube_test{1,2,3,4,5,6}
|
$ npm run clean:server:test
|
||||||
```
|
```
|
||||||
|
|
||||||
Build the application and run the unit/integration tests:
|
Build the application and run the unit/integration tests:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ npm run build
|
$ npm run build -- --light
|
||||||
$ npm test
|
$ npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ export class AuthService {
|
||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
grant_type: 'password',
|
grant_type: 'password',
|
||||||
scope: 'upload',
|
scope: 'upload',
|
||||||
username: username.toLowerCase(),
|
username,
|
||||||
password
|
password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -367,7 +367,7 @@ export class UserModel extends Model<UserModel> {
|
||||||
static loadByUsername (username: string) {
|
static loadByUsername (username: string) {
|
||||||
const query = {
|
const query = {
|
||||||
where: {
|
where: {
|
||||||
username
|
username: { [ Op.iLike ]: username }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ export class UserModel extends Model<UserModel> {
|
||||||
static loadByUsernameAndPopulateChannels (username: string) {
|
static loadByUsernameAndPopulateChannels (username: string) {
|
||||||
const query = {
|
const query = {
|
||||||
where: {
|
where: {
|
||||||
username
|
username: { [ Op.iLike ]: username }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +399,7 @@ export class UserModel extends Model<UserModel> {
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
where: {
|
where: {
|
||||||
[ Op.or ]: [ { username }, { email } ]
|
[ Op.or ]: [ { username: { [ Op.iLike ]: username } }, { email } ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,17 @@ describe('Test users', function () {
|
||||||
|
|
||||||
accessToken = res.body.access_token
|
accessToken = res.body.access_token
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should be able to login with an insensitive username', async function () {
|
||||||
|
const user = { username: 'RoOt', password: server.user.password }
|
||||||
|
const res = await login(server.url, server.client, user, 200)
|
||||||
|
|
||||||
|
const user2 = { username: 'rOoT', password: server.user.password }
|
||||||
|
const res2 = await login(server.url, server.client, user2, 200)
|
||||||
|
|
||||||
|
const user3 = { username: 'ROOt', password: server.user.password }
|
||||||
|
const res3 = await login(server.url, server.client, user3, 200)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Upload', function () {
|
describe('Upload', function () {
|
||||||
|
|
Loading…
Reference in New Issue