Compare commits
3 Commits
ece9569d66
...
6fef87b0f1
Author | SHA1 | Date |
---|---|---|
|
6fef87b0f1 | |
|
0d7a03f3e5 | |
|
1703e9a541 |
|
@ -64,6 +64,12 @@ async function login() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mounted() {
|
||||||
|
if (!this.$store.state.auth.enabled) {
|
||||||
|
this.$router.replace({ name: 'not-found' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -73,6 +79,7 @@ export default {
|
||||||
error: null,
|
error: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
mounted,
|
||||||
methods: {
|
methods: {
|
||||||
login,
|
login,
|
||||||
},
|
},
|
||||||
|
|
|
@ -73,6 +73,12 @@ async function signup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mounted() {
|
||||||
|
if (!this.$store.state.auth.enabled) {
|
||||||
|
this.$router.replace({ name: 'not-found' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -83,6 +89,7 @@ export default {
|
||||||
error: null,
|
error: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
mounted,
|
||||||
methods: {
|
methods: {
|
||||||
signup,
|
signup,
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<ul class="menu-items noselect">
|
<ul class="menu-items noselect">
|
||||||
<router-link
|
<router-link
|
||||||
v-if="me"
|
v-if="auth && me"
|
||||||
:to="{ name: 'user', params: { username: me.username } }"
|
:to="{ name: 'user', params: { username: me.username } }"
|
||||||
class="menu-username"
|
class="menu-username"
|
||||||
>{{ me.username }}</router-link>
|
>{{ me.username }}</router-link>
|
||||||
|
|
||||||
<router-link
|
<router-link
|
||||||
v-else
|
v-else-if="auth"
|
||||||
:to="{ name: 'login', query: { ref: $route.path } }"
|
:to="{ name: 'login', query: { ref: $route.path } }"
|
||||||
class="menu-item"
|
class="menu-item"
|
||||||
@click.stop
|
@click.stop
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<li
|
<li
|
||||||
v-if="me"
|
v-if="auth && me"
|
||||||
class="menu-item"
|
class="menu-item"
|
||||||
@click.stop="$store.dispatch('logout')"
|
@click.stop="$store.dispatch('logout')"
|
||||||
>
|
>
|
||||||
|
@ -89,6 +89,10 @@ function theme(state) {
|
||||||
return state.ui.theme;
|
return state.ui.theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function auth(state) {
|
||||||
|
return state.auth.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
function me(state) {
|
function me(state) {
|
||||||
return state.auth.user;
|
return state.auth.user;
|
||||||
}
|
}
|
||||||
|
@ -104,6 +108,7 @@ function setSfw(enabled) {
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
|
auth,
|
||||||
sfw,
|
sfw,
|
||||||
theme,
|
theme,
|
||||||
me,
|
me,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
export default {
|
export default {
|
||||||
|
enabled: window.env.auth,
|
||||||
user: null,
|
user: null,
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,6 +33,9 @@ module.exports = {
|
||||||
accessKey: 'ABCDEFGHIJ1234567890',
|
accessKey: 'ABCDEFGHIJ1234567890',
|
||||||
secretKey: 'abcdefghijklmnopqrstuvwxyz1234567890ABCD',
|
secretKey: 'abcdefghijklmnopqrstuvwxyz1234567890ABCD',
|
||||||
},
|
},
|
||||||
|
auth: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
exclude: {
|
exclude: {
|
||||||
channels: [
|
channels: [
|
||||||
// 21sextreme, no longer updated
|
// 21sextreme, no longer updated
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.184.2",
|
"version": "1.185.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "1.184.2",
|
"version": "1.185.0",
|
||||||
"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.184.2",
|
"version": "1.185.0",
|
||||||
"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": {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const config = require('config');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
@ -21,6 +22,10 @@ async function verifyPassword(password, storedPassword) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function login(credentials) {
|
async function login(credentials) {
|
||||||
|
if (!config.auth.enabled) {
|
||||||
|
throw new HttpError('Authentication is disabled', 405);
|
||||||
|
}
|
||||||
|
|
||||||
const user = await fetchUser(credentials.username, true);
|
const user = await fetchUser(credentials.username, true);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
@ -33,6 +38,10 @@ async function login(credentials) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function signup(credentials) {
|
async function signup(credentials) {
|
||||||
|
if (!config.auth.enabled) {
|
||||||
|
throw new HttpError('Authentication is disabled', 405);
|
||||||
|
}
|
||||||
|
|
||||||
if (!credentials.username) {
|
if (!credentials.username) {
|
||||||
throw new HttpError('Username required', 400);
|
throw new HttpError('Username required', 400);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ function getLimiter(options = {}, url) {
|
||||||
return limiters[interval][concurrency];
|
return limiters[interval][concurrency];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function request(method = 'get', url, body, requestOptions = {}, limiter) {
|
async function request(method = 'get', url, body, requestOptions = {}, limiter, timeout) {
|
||||||
const http = requestOptions.session || bhttp;
|
const http = requestOptions.session || bhttp;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
|
@ -107,7 +107,7 @@ async function request(method = 'get', url, body, requestOptions = {}, limiter)
|
||||||
? http[method](url, body, options)
|
? http[method](url, body, options)
|
||||||
: http[method](url, options));
|
: http[method](url, options));
|
||||||
|
|
||||||
const resIsOk = res.statusCode >= 200 && res.statusCode <= 299;
|
timeout.cancel();
|
||||||
|
|
||||||
if (options.destination) {
|
if (options.destination) {
|
||||||
// res.on('progress', (bytes, totalBytes) => logger.silly(`Downloaded ${Math.round((bytes / totalBytes) * 100)}% of ${url}`));
|
// res.on('progress', (bytes, totalBytes) => logger.silly(`Downloaded ${Math.round((bytes / totalBytes) * 100)}% of ${url}`));
|
||||||
|
@ -126,7 +126,7 @@ async function request(method = 'get', url, body, requestOptions = {}, limiter)
|
||||||
status: res.statusCode,
|
status: res.statusCode,
|
||||||
document: window.document,
|
document: window.document,
|
||||||
window,
|
window,
|
||||||
ok: resIsOk,
|
ok: res.statusCode >= 200 && res.statusCode <= 299,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,9 +152,7 @@ async function scheduleRequest(method = 'get', url, body, options) {
|
||||||
const limiter = getLimiter(options, url);
|
const limiter = getLimiter(options, url);
|
||||||
const timeout = getTimeout(options, url);
|
const timeout = getTimeout(options, url);
|
||||||
|
|
||||||
const result = await limiter.schedule(() => Promise.race([request(method, url, body, options, limiter), timeout]));
|
const result = await limiter.schedule(() => Promise.race([request(method, url, body, options, limiter, timeout), timeout]));
|
||||||
|
|
||||||
timeout.cancel();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,7 @@ async function initServer() {
|
||||||
res.render(path.join(__dirname, '../../assets/index.ejs'), {
|
res.render(path.join(__dirname, '../../assets/index.ejs'), {
|
||||||
env: JSON.stringify({
|
env: JSON.stringify({
|
||||||
sfw: !!req.headers.sfw || Object.prototype.hasOwnProperty.call(req.query, 'sfw'),
|
sfw: !!req.headers.sfw || Object.prototype.hasOwnProperty.call(req.query, 'sfw'),
|
||||||
|
auth: config.auth.enabled,
|
||||||
sessionId: req.session.safeId,
|
sessionId: req.session.safeId,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue