Hiding scene photos and trailers from guests.

This commit is contained in:
DebaucheryLibrarian 2021-05-15 02:51:52 +02:00
parent 83ed793e39
commit 846b860c06
4 changed files with 60 additions and 4 deletions

View File

@ -107,6 +107,14 @@
</span> </span>
</a> </a>
</div> </div>
<div
v-if="!me"
class="item-container item-more"
><router-link
:to="{ name: 'signup', query: { ref: $route.path } }"
class="link"
>Sign up</router-link>&nbsp;for more photos, trailers and features!</div>
</div> </div>
</div> </div>
</template> </template>
@ -118,6 +126,10 @@ function sfw() {
return this.$store.state.ui.sfw; return this.$store.state.ui.sfw;
} }
function me() {
return this.$store.state.auth.user;
}
function poster() { function poster() {
if (this.release.poster) { if (this.release.poster) {
return this.getPath(this.release.poster, 'thumbnail'); return this.getPath(this.release.poster, 'thumbnail');
@ -181,6 +193,7 @@ export default {
}; };
}, },
computed: { computed: {
me,
photos, photos,
poster, poster,
sfw, sfw,
@ -191,10 +204,6 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
@import 'breakpoints'; @import 'breakpoints';
.media-container {
backdrop-filter: blur(1rem);
}
.media { .media {
flex-shrink: 0; flex-shrink: 0;
white-space: nowrap; white-space: nowrap;
@ -204,6 +213,7 @@ export default {
.media.center { .media.center {
width: 1200px; width: 1200px;
max-width: 100%; max-width: 100%;
display: flex;
margin: 0 auto; margin: 0 auto;
} }
@ -284,6 +294,22 @@ export default {
background-size: cover; background-size: cover;
} }
.item-more {
height: auto;
flex-grow: 1;
align-items: center;
padding: .5rem 2rem;
color: var(--text-light);
text-shadow: 0 0 3px var(--darken);
font-weight: bold;
font-size: 1rem;
.link {
color: inherit;
text-decoration: underline;
}
}
.trailer-container { .trailer-container {
width: 32rem; width: 32rem;
max-width: 100%; max-width: 100%;
@ -311,6 +337,14 @@ export default {
} }
@media(max-width: $breakpoint-micro) { @media(max-width: $breakpoint-micro) {
.media.center {
flex-direction: column;
}
.item-more {
font-size: .9rem;
}
.media:not(.expanded) .item, .media:not(.expanded) .item,
.trailer-container { .trailer-container {
height: 56vw; /* 16:9 ratio for full-width video */ height: 56vw; /* 16:9 ratio for full-width video */

View File

@ -327,6 +327,10 @@ export default {
.banner { .banner {
background-position: center; background-position: center;
background-size: cover; background-size: cover;
::v-deep .scrollable {
backdrop-filter: blur(1rem);
}
} }
.info { .info {

View File

@ -1574,6 +1574,12 @@ exports.up = knex => Promise.resolve()
CREATE POLICY notifications_policy_update ON notifications FOR UPDATE USING (notifications.user_id = current_user_id()); CREATE POLICY notifications_policy_update ON notifications FOR UPDATE USING (notifications.user_id = current_user_id());
CREATE POLICY notifications_policy_delete ON notifications FOR DELETE USING (notifications.user_id = current_user_id()); CREATE POLICY notifications_policy_delete ON notifications FOR DELETE USING (notifications.user_id = current_user_id());
CREATE POLICY notifications_policy_insert ON notifications FOR INSERT WITH CHECK (true); CREATE POLICY notifications_policy_insert ON notifications FOR INSERT WITH CHECK (true);
ALTER TABLE releases_photos ENABLE ROW LEVEL SECURITY;
CREATE POLICY releases_photos_select ON releases_photos FOR SELECT USING (current_user_id() IS NOT NULL);
ALTER TABLE releases_trailers ENABLE ROW LEVEL SECURITY;
CREATE POLICY releases_trailers_select ON releases_trailers FOR SELECT USING (current_user_id() IS NOT NULL);
`, { `, {
visitor: knex.raw(config.database.query.user), visitor: knex.raw(config.database.query.user),
}); });

View File

@ -62,6 +62,10 @@ const {
updateNotification, updateNotification,
} = require('./alerts'); } = require('./alerts');
function getIp(req) {
return req.headers['x-forwarded-for'] ? req.headers['x-forwarded-for'].split(',')[0] : req.connection.remoteAddress; // See src/ws
}
async function initServer() { async function initServer() {
const app = express(); const app = express();
const router = Router(); const router = Router();
@ -87,6 +91,14 @@ async function initServer() {
next(); next();
}); });
router.use((req, res, next) => {
const ip = getIp(req);
logger.silly(`${ip} (${req.headers['CF-IPCountry'] || 'country N/A'}) requested ${req.originalUrl} as ${req.session.user ? `${req.session.user.username} (${req.session.user.id})` : 'guest'}`);
next();
});
router.get('/api/session', fetchMe); router.get('/api/session', fetchMe);
router.post('/api/session', login); router.post('/api/session', login);
router.delete('/api/session', logout); router.delete('/api/session', logout);