Compare commits
No commits in common. "81f504f33e4f40225f8af81141782662139ad4d1" and "1fc441670bda38348a8fd395aad01ce64ea2a06c" have entirely different histories.
81f504f33e
...
1fc441670b
|
@ -37,8 +37,6 @@ module.exports = {
|
||||||
auth: {
|
auth: {
|
||||||
login: true,
|
login: true,
|
||||||
signup: true,
|
signup: true,
|
||||||
usernameLength: [2, 24],
|
|
||||||
usernamePattern: /^[a-zA-Z0-9_-]$/,
|
|
||||||
},
|
},
|
||||||
exclude: {
|
exclude: {
|
||||||
channels: [
|
channels: [
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.227.3",
|
"version": "1.227.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.227.3",
|
"version": "1.227.2",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@casl/ability": "^5.2.2",
|
"@casl/ability": "^5.2.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.227.3",
|
"version": "1.227.2",
|
||||||
"description": "All the latest porn releases in one place",
|
"description": "All the latest porn releases in one place",
|
||||||
"main": "src/app.js",
|
"main": "src/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
22
src/auth.js
22
src/auth.js
|
@ -26,7 +26,7 @@ async function login(credentials) {
|
||||||
throw new HttpError('Authentication is disabled', 405);
|
throw new HttpError('Authentication is disabled', 405);
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await fetchUser(credentials.username.trim(), true);
|
const user = await fetchUser(credentials.username, true);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
throw new HttpError('Username or password incorrect', 401);
|
throw new HttpError('Username or password incorrect', 401);
|
||||||
|
@ -46,24 +46,10 @@ async function signup(credentials) {
|
||||||
throw new HttpError('Authentication is disabled', 405);
|
throw new HttpError('Authentication is disabled', 405);
|
||||||
}
|
}
|
||||||
|
|
||||||
const curatedUsername = credentials.username.trim();
|
if (!credentials.username) {
|
||||||
|
|
||||||
if (!curatedUsername) {
|
|
||||||
throw new HttpError('Username required', 400);
|
throw new HttpError('Username required', 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curatedUsername.length < config.auth.usernameLength[0]) {
|
|
||||||
throw new HttpError('Username is too short', 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curatedUsername.length > config.auth.usernameLength[1]) {
|
|
||||||
throw new HttpError('Username is too long', 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!config.auth.usernamePattern.test(curatedUsername)) {
|
|
||||||
throw new HttpError('Username contains invalid characters', 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!credentials.email) {
|
if (!credentials.email) {
|
||||||
throw new HttpError('E-mail required', 400);
|
throw new HttpError('E-mail required', 400);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +59,7 @@ async function signup(credentials) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingUser = await knex('users')
|
const existingUser = await knex('users')
|
||||||
.where('username', curatedUsername)
|
.where('username', credentials.username)
|
||||||
.orWhere('email', credentials.email)
|
.orWhere('email', credentials.email)
|
||||||
.first();
|
.first();
|
||||||
|
|
||||||
|
@ -87,7 +73,7 @@ async function signup(credentials) {
|
||||||
|
|
||||||
const [userId] = await knex('users')
|
const [userId] = await knex('users')
|
||||||
.insert({
|
.insert({
|
||||||
username: curatedUsername,
|
username: credentials.username,
|
||||||
email: credentials.email,
|
email: credentials.email,
|
||||||
password: storedPassword,
|
password: storedPassword,
|
||||||
})
|
})
|
||||||
|
|
|
@ -120,7 +120,7 @@ async function load() {
|
||||||
|
|
||||||
const user = await knex('users')
|
const user = await knex('users')
|
||||||
.select('id')
|
.select('id')
|
||||||
.where('username', stash.username.trim())
|
.where('username', stash.username)
|
||||||
.first();
|
.first();
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
|
Loading…
Reference in New Issue