forked from kaverti/website
0.177-prerelease1 (BROKEN ROUTES)
This commit is contained in:
parent
76de4778e8
commit
c001ef2b32
2556
frontend/src/App.vue
2556
frontend/src/App.vue
File diff suppressed because it is too large
Load Diff
|
@ -89,14 +89,14 @@
|
|||
return value.toUpperCase()
|
||||
},
|
||||
doBoth() {
|
||||
this.savePreferences()
|
||||
this.saveExperiments()
|
||||
this.localExperiments()
|
||||
},
|
||||
localExperiments() {
|
||||
localStorage.setItem('experimentsStore', JSON.stringify({wall: this.experiments.wall, theme: this.experiments.theme, relationships: this.experiments.relationships, teams: this.experiments.teams, marketplace: this.experiments.marketplace}));
|
||||
this.setExperimentsStore()
|
||||
},
|
||||
savePreferences() {
|
||||
saveExperiments() {
|
||||
this.experiments.error = ''
|
||||
this.experiments.loading = true
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</style>
|
||||
<template>
|
||||
<main>
|
||||
<section v-if="!$store.state.experimentsStore.teams" class="hero is-info is-large">
|
||||
<section class="hero is-info is-large" v-if="!$store.state.experimentsStore.teams">
|
||||
<div class="hero-body">
|
||||
<div class="container">
|
||||
<h2>
|
||||
|
@ -32,6 +32,66 @@
|
|||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<b-modal :active="createTeamModal" v-model="createTeamModal">
|
||||
<div class="modal-card" style="width: auto">
|
||||
<template>
|
||||
<div class='route_container section route_container--settings'>
|
||||
<div class='column box'>
|
||||
<tab-view
|
||||
:tabs='["Create your own Team!"]'
|
||||
v-model="showTeamTab"
|
||||
padding='true'
|
||||
slot='main'
|
||||
>
|
||||
<template slot='Create your own Team!'>
|
||||
<p style='margin-top: 0;'>
|
||||
Creating a Kaverti team is easy!<br>
|
||||
Just fill out the form here, you will be redirected to your team page automatically!<br>
|
||||
Kaverti Teams cost 300 Koins to create.
|
||||
</p>
|
||||
<br/>
|
||||
|
||||
<form>
|
||||
<fancy-input
|
||||
ref='input'
|
||||
v-model='tcreateProd.username'
|
||||
:error='tcreateProd.errors.username'
|
||||
placeholder='Username'
|
||||
width='100%'
|
||||
>
|
||||
</fancy-input>
|
||||
<fancy-input
|
||||
v-model='tcreateProd.name'
|
||||
:error='tcreateProd.errors.name'
|
||||
placeholder='Name'
|
||||
width='100%'
|
||||
type="email"
|
||||
>
|
||||
</fancy-input>
|
||||
By pressing the "Create Team" button, you agree to the <router-link to="/legal/tos" v-on:click.native="closeAccountModal">Kaverti Terms of Service</router-link> and have read the <router-link to="/legal/privacy" v-on:click.native="closeAccountModal">Privacy Policy</router-link>.
|
||||
<div style='margin-top: 0.5rem;'>
|
||||
<b-button
|
||||
class='is-info'
|
||||
style="width: 55%"
|
||||
:loading='tcreateProd.loading'
|
||||
@click='createTeam'
|
||||
v-if='!$store.state.meta.RegistrationsDisabled'
|
||||
>
|
||||
Create Team
|
||||
</b-button>
|
||||
|
||||
<b-button style="float: right" class="is-danger-passive" @click='closeAccountModal'>
|
||||
Cancel
|
||||
</b-button>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
</tab-view>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</b-modal>
|
||||
<section v-if='$store.state.experimentsStore.teams' class="hero is-info">
|
||||
<div class="hero-body" style="padding: 1rem 1rem !important;">
|
||||
<div class="mobile-container">
|
||||
|
@ -43,8 +103,8 @@
|
|||
</section>
|
||||
<div class="section" v-if="$store.state.experimentsStore.teams">
|
||||
<div class="">
|
||||
<div class="column">
|
||||
<b-button class="is-primary">Create Team</b-button>
|
||||
<div class="column" v-if="$store.state.username">
|
||||
<b-button @click="createTeamModal = true" class="is-primary">Create Team</b-button>
|
||||
</div>
|
||||
<scroll-load
|
||||
key='user-row'
|
||||
|
@ -91,6 +151,8 @@
|
|||
<script>
|
||||
import LoadingMessage from '../LoadingMessage';
|
||||
import ScrollLoad from '../ScrollLoad';
|
||||
import TabView from '../TabView'
|
||||
import FancyInput from '../FancyInput'
|
||||
import throttle from 'lodash.throttle';
|
||||
import AjaxErrorHandler from '../../assets/js/errorHandler';
|
||||
|
||||
|
@ -98,7 +160,9 @@
|
|||
name: 'UserList',
|
||||
components: {
|
||||
LoadingMessage,
|
||||
ScrollLoad
|
||||
ScrollLoad,
|
||||
TabView,
|
||||
FancyInput
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
@ -108,6 +172,19 @@
|
|||
loading: true,
|
||||
offset: 0,
|
||||
limit: 15,
|
||||
showTeamTab: 0,
|
||||
createTeamModal: false,
|
||||
tcreateProd: {
|
||||
username: '',
|
||||
name: '',
|
||||
|
||||
loading: false,
|
||||
|
||||
errors: {
|
||||
username: '',
|
||||
name: ''
|
||||
}
|
||||
},
|
||||
|
||||
roleOptions: [
|
||||
{ name: 'Admins', value: 'admin' },
|
||||
|
@ -122,6 +199,29 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
clearTeamErrors() {
|
||||
this.tcreateProd.errors.username = ''
|
||||
this.tcreateProd.errors.name = ''
|
||||
},
|
||||
closeAccountModal() {
|
||||
this.createTeamModal = false
|
||||
},
|
||||
createTeam() {
|
||||
let postParams = {
|
||||
username: this.tcreateProd.username,
|
||||
name: this.tcreateProd.name
|
||||
}
|
||||
this.tcreateProd.loading = true
|
||||
|
||||
this.axios.post(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `teams/create`, postParams).then(res => {
|
||||
this.signup.loading = false
|
||||
this.$store.commit('setUsername', res.data.username)
|
||||
this.closeAccountModal()
|
||||
}).catch(e => {
|
||||
this.tcreateProd.loading = false
|
||||
AjaxErrorHandler(this.$store)(e);
|
||||
})
|
||||
},
|
||||
fetchData () {
|
||||
if(this.offset === null) return;
|
||||
|
||||
|
|
|
@ -227,20 +227,6 @@
|
|||
AjaxErrorHandler(this.$store)(e)
|
||||
}
|
||||
})
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data)
|
||||
.catch(e => {
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
return error.name === 'accountDoesNotExist'
|
||||
})
|
||||
|
||||
if(invalidId) {
|
||||
this.$store.commit('set404Page', true)
|
||||
} else {
|
||||
AjaxErrorHandler(this.$store)(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -20,12 +20,14 @@ export default new Vuex.Store({
|
|||
},
|
||||
accountTabs: 0,
|
||||
accountModal: false,
|
||||
username: '',
|
||||
settingsTabs: 0,
|
||||
settingsModal: true,
|
||||
username: '',
|
||||
admin: false,
|
||||
koins: '',
|
||||
email: '',
|
||||
emailVerified: true,
|
||||
clientVersion: '0.176-stable',
|
||||
clientVersion: '0.177-stable',
|
||||
latestClientVersion: '',
|
||||
developerMode: false,
|
||||
theme: '',
|
||||
|
@ -115,12 +117,18 @@ export default new Vuex.Store({
|
|||
setAccountTabs(state, index) {
|
||||
state.accountTabs = index;
|
||||
},
|
||||
setSettingsTabs(state, index) {
|
||||
state.settingsTabs = index;
|
||||
},
|
||||
setSelectOptions(state, payload) {
|
||||
state.selectOptions[payload.name] = payload.value;
|
||||
},
|
||||
setAccountModalState(state, value) {
|
||||
state.accountModal = value;
|
||||
},
|
||||
setSettingsModalState(state, value) {
|
||||
state.settingsModal = value;
|
||||
},
|
||||
setGateway(state, value) {
|
||||
state.gateway = value;
|
||||
},
|
||||
|
|
|
@ -14,9 +14,11 @@ module.exports = async(req, res, next) => {
|
|||
req.userData = decoded;
|
||||
next()
|
||||
} else {
|
||||
return res.status(200).json({"errors":[{"name":"requestNotAuthorized","message":"You aren't logged in, or you don't have permission to perform this action.","status":401}]});
|
||||
res.status(200)
|
||||
res.json({loggedIn: false})
|
||||
}
|
||||
} catch {
|
||||
return res.status(200).json({"errors":[{"name":"requestNotAuthorized","message":"You aren't logged in, or you don't have permission to perform this action.","status":401}]});
|
||||
res.status(200)
|
||||
res.json({loggedIn: false})
|
||||
}
|
||||
};
|
||||
|
|
|
@ -130,6 +130,10 @@ let Errors = {
|
|||
'You can only get Koins from this method once a day.',
|
||||
400
|
||||
],
|
||||
koinLimit: [
|
||||
'I don\'t know how you did it, but you did, you managed to reach the Kave' + 'rti Koin limit, how is that possible? Who knows.',
|
||||
400
|
||||
],
|
||||
lockedCategory: [
|
||||
'This category is locked, only admins can post here, however, you can still respond to existing threads if they aren\'t locked',
|
||||
400
|
||||
|
|
|
@ -63,9 +63,9 @@ module.exports = (sequelize, DataTypes) => {
|
|||
associate (models) {
|
||||
Category.hasMany(models.Thread)
|
||||
},
|
||||
async AdminOnlyFunc() {
|
||||
async AdminOnlyFunc(user) {
|
||||
|
||||
if(Category && Category.AdminOnly && !user.session.admin) {
|
||||
if(Category && Category.AdminOnly && !user.admin) {
|
||||
throw Errors.sequelizeValidation(sequelize.Sequelize, {
|
||||
error: 'Only admins can access this category'
|
||||
})
|
||||
|
|
|
@ -128,7 +128,7 @@ router.put('/user/modify', auth, async(req, res, next) => {
|
|||
router.get('/privileges', auth, async(req, res, next) => {
|
||||
try {
|
||||
let queryObj = {
|
||||
attributes: {include: ['username', 'admin', 'executive'], exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'description', 'theme', 'contributor', 'passwordResetOptOut', 'picture', 'createdAt', 'updatedAt', 'id']},
|
||||
attributes: {include: ['username', 'admin', 'executive'], exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset', 'description', 'theme', 'contributor', 'passwordResetOptOut', 'picture', 'createdAt', 'updatedAt', 'id']},
|
||||
where: {username: req.userData.username}
|
||||
}
|
||||
let user = await User.findOne(queryObj)
|
||||
|
|
|
@ -6,8 +6,13 @@ const Errors = require('../lib/errors')
|
|||
let pagination = require('../lib/pagination')
|
||||
let { Category, Post, Thread, User, Sequelize } = require('../models')
|
||||
|
||||
router.get('/', async(req, res) => {
|
||||
router.get('/', auth, async(req, res) => {
|
||||
try {
|
||||
let queryObj = {
|
||||
attributes: {exclude: ['hash', 'currency2', 'emailToken', 'passwordResetToken', 'deleteCode', 'deleteEnabled', 'jwtOffset']},
|
||||
where: {username: req.userData.username}
|
||||
}
|
||||
let user = await User.findOne(queryObj)
|
||||
let categories = await Category.findAll()
|
||||
|
||||
res.json(categories)
|
||||
|
|
|
@ -10,7 +10,7 @@ router.get('/:id', auth, async(req, res, next) => {
|
|||
let id = req.params.id
|
||||
let pollQuestion = await PollQuestion.findById(id, {
|
||||
include: [
|
||||
{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode'] } },
|
||||
{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset'] } },
|
||||
{ model: PollAnswer, include: [PollVote] }
|
||||
]
|
||||
})
|
||||
|
|
|
@ -74,8 +74,8 @@ router.get('/', auth, async(req, res, next) => {
|
|||
try {
|
||||
let reports = await Report.findAll({
|
||||
include: [
|
||||
{ model: User, as: 'FlaggedByUser', attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode'] } },
|
||||
{ model: Post, include: Post.includeOptions(), attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode'] } }
|
||||
{ model: User, as: 'FlaggedByUser', attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset'] } },
|
||||
{ model: Post, include: Post.includeOptions(), attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset'] } }
|
||||
]
|
||||
})
|
||||
|
||||
|
|
|
@ -45,13 +45,13 @@ router.get('/thread', async(req, res, next) => {
|
|||
include: [
|
||||
{
|
||||
model: Post,
|
||||
include: [{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode']} }],
|
||||
include: [{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset']} }],
|
||||
where: {
|
||||
postNumber: 0
|
||||
}
|
||||
},
|
||||
{ model: Category },
|
||||
{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode'] } }
|
||||
{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset'] } }
|
||||
],
|
||||
limit
|
||||
})
|
||||
|
@ -64,14 +64,14 @@ router.get('/thread', async(req, res, next) => {
|
|||
include: [
|
||||
{
|
||||
model: Post,
|
||||
include: [{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode'] } }],
|
||||
include: [{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset'] } }],
|
||||
where: {
|
||||
postNumber: 0,
|
||||
plainText: { $like: '%' + searchString + '%' }
|
||||
}
|
||||
},
|
||||
{ model: Category },
|
||||
{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode'] } }
|
||||
{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset'] } }
|
||||
],
|
||||
limit
|
||||
})
|
||||
|
@ -113,7 +113,7 @@ router.get('/thread', async(req, res, next) => {
|
|||
$or: whereClause
|
||||
},
|
||||
order: [ ['ThreadId', 'DESC'] ],
|
||||
include: [{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode'] } }]
|
||||
include: [{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset'] } }]
|
||||
})
|
||||
|
||||
//Merge latest posts with threads array
|
||||
|
@ -145,7 +145,7 @@ router.get('/user', async(req, res, next) => {
|
|||
username: { $like: '%' + searchString + '%' }
|
||||
},
|
||||
order: [ ['username', 'DESC'] ],
|
||||
attributes: {exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode']},
|
||||
attributes: {exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset']},
|
||||
limit,
|
||||
offset
|
||||
})
|
||||
|
|
|
@ -11,7 +11,7 @@ router.get('/users', auth, async(req, res, next) => {
|
|||
username
|
||||
},
|
||||
order: [ ['username', 'DESC'] ],
|
||||
attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode'] },
|
||||
attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset'] },
|
||||
offset
|
||||
})
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ router.post('/job-application', auth, async(req, res, next) => {
|
|||
router.get('/:username', async(req, res, next) => {
|
||||
try {
|
||||
let queryObj = {
|
||||
attributes: {exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode']},
|
||||
attributes: {exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset']},
|
||||
where: {username: req.params.username}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ let { User, Ban } = require('../models')
|
|||
router.get('/', auth, auth, async(req, res, next) => {
|
||||
try {
|
||||
let queryObj = {
|
||||
attributes: {exclude: ['hash', 'currency2', 'emailToken', 'passwordResetToken', 'deleteCode', 'deleteEnabled']},
|
||||
attributes: {exclude: ['hash', 'currency2', 'emailToken', 'passwordResetToken', 'deleteCode', 'deleteEnabled', 'jwtOffset']},
|
||||
where: {username: req.userData.username}
|
||||
}
|
||||
let user = await User.findOne(queryObj)
|
||||
|
@ -17,6 +17,7 @@ router.get('/', auth, auth, async(req, res, next) => {
|
|||
errors: ["Please login to use this endpoint, idk what you expected"]
|
||||
})
|
||||
}
|
||||
res.status(200)
|
||||
res.json(user.toJSON())
|
||||
|
||||
} catch (err) { next(err) }
|
||||
|
|
|
@ -180,6 +180,12 @@ router.get('/reward', auth, async(req, res, next) => {
|
|||
let dayMs = 1000 * 60 * 60 * 24
|
||||
|
||||
let check = await ms / dayMs < 1
|
||||
if(user.koins === 9223372036854775808) {
|
||||
res.status(401)
|
||||
res.json({
|
||||
errors: [Errors.koinLimit], koins: user.koins
|
||||
})
|
||||
}
|
||||
if (check) {
|
||||
res.status(401)
|
||||
res.json({
|
||||
|
|
Loading…
Reference in New Issue