Added ability to ban users from admin console. Added custom error messages when users are banned. Added account status check when making new posts

This commit is contained in:
jay.poff@outlook.com
2021-03-28 15:20:36 -05:00
parent 1f37e49fc2
commit 7e4d74a882
12 changed files with 606 additions and 88 deletions

View File

@@ -21,6 +21,7 @@ const UserSchema = new Schema({
default: 0
},
ban_lift_date: Date,
ban_reason: String,
official: {
type: Boolean,
default: false

View File

@@ -319,4 +319,119 @@ router.get('/users/all', function (req, res) {
});
});
router.get('/users/:userID', function (req, res) {
database.connect().then(async e => {
if(req.cookies.token === null)
throw new Error('No service token supplied');
let pid = util.data.processServiceToken(req.cookies.token);
if(pid === null)
throw new Error('Invalid credentials supplied');
let user = await database.getUserByPID(pid);
if(user !== null)
{
if(config.authorized_PNIDs.indexOf(user.pid) === -1)
throw new Error('Invalid credentials supplied');
res.send(await database.getUserByPID(req.params.userID))
}
else
throw new Error('Invalid account ID or password');
}).catch(error =>
{
res.statusCode = 400;
let response = {
error_code: 400,
message: error.message
};
res.send(response);
});
});
router.post('/users/:userID/update', upload.none(), function (req, res) {
database.connect().then(async e => {
if(req.cookies.token === null)
throw new Error('No service token supplied');
let pid = util.data.processServiceToken(req.cookies.token);
if(pid === null)
throw new Error('Invalid credentials supplied');
let parentUser = await database.getUserByPID(pid);
let user = await database.getUserByPID(req.params.userID);
if(user !== null)
{
if(config.authorized_PNIDs.indexOf(parentUser.pid) === -1)
throw new Error('Invalid credentials supplied');
user.account_status = req.body.account_status;
user.ban_reason = req.body.ban_reason;
user.ban_lift_date = moment(req.body.ban_date);
user.save();
res.sendStatus(200);
logger.audit('[' + parentUser.user_id + ' - ' + parentUser.pid + '] banned ' + user.user_id + ' until ' + user.ban_lift_date + ' for ' + user.ban_reason);
}
else
throw new Error('Invalid account ID or password');
}).catch(error =>
{
res.statusCode = 400;
let response = {
error_code: 400,
message: error.message
};
res.send(response);
});
});
router.post('/posts/:postID/delete', function (req, res) {
database.connect().then(async e => {
if(req.cookies.token === null)
throw new Error('No service token supplied');
let pid = util.data.processServiceToken(req.cookies.token);
if(pid === null)
throw new Error('Invalid credentials supplied');
let user = await database.getUserByPID(pid);
if(user !== null)
{
if(config.authorized_PNIDs.indexOf(user.pid) === -1) {
logger.audit('[' + user.user_id + ' - ' + user.pid + '] attempted to delete a community and is not authorized');
throw new Error('Invalid credentials supplied');
}
let post = await database.getPostByID(req.params.postID);
if(post !== null) {
post.delete().then(err => function () {
res.send(err);
});
res.sendStatus(200);
logger.audit('[' + user.user_id + ' - ' + user.pid + '] deleted post by ' + post.screen_name);
}
else
res.sendStatus(404)
}
else
throw new Error('Invalid account ID or password');
}).catch(error =>
{
res.statusCode = 400;
let response = {
error_code: 400,
message: error.message
};
res.send(response);
});
});
module.exports = router;

View File

@@ -1,11 +1,12 @@
var express = require('express');
var xml = require('object-to-xml');
const database = require('../../../../database');
const logger = require('../../../../logger');
const util = require('../../../../authentication');
const config = require('../../../../config.json');
const request = require("request");
var path = require('path');
const ejs = require('ejs');
var moment = require('moment');
var multer = require('multer');
var upload = multer({ dest: 'uploads/' });
var router = express.Router();
@@ -143,8 +144,6 @@ router.get('/communities', upload.none(), function (req, res) {
router.get('/audit', upload.none(), function (req, res) {
database.connect().then(async e => {
//let paramPackData = util.data.decodeParamPack(req.headers["x-nintendo-parampack"]);
if(req.cookies.token === null)
{
res.redirect('/login');
@@ -152,7 +151,6 @@ router.get('/audit', upload.none(), function (req, res) {
}
let pid = util.data.processServiceToken(req.cookies.token);
//console.log(req.headers["x-nintendo-servicetoken"]);
if(pid === null)
{
res.redirect('/login');
@@ -222,48 +220,6 @@ router.get('/communities/new', upload.none(), function (req, res) {
});
router.get('/communities/:communityID/edit', upload.none(), function (req, res) {
database.connect().then(async e => {
//let paramPackData = util.data.decodeParamPack(req.headers["x-nintendo-parampack"]);
if(req.cookies.token === null)
{
res.redirect('/login');
return;
}
let pid = util.data.processServiceToken(req.cookies.token);
//console.log(req.headers["x-nintendo-servicetoken"]);
if(pid === null)
{
res.redirect('/login');
return;
}
let user = await database.getUserByPID(pid);
let community = await database.getCommunityByID(req.params.communityID.toString());
res.render('admin_edit_community.ejs', {
user: user,
community: community,
});
}).catch(error => {
console.log(error);
res.set("Content-Type", "application/xml");
res.statusCode = 400;
response = {
result: {
has_error: 1,
version: 1,
code: 400,
error_code: 15,
message: "SERVER_ERROR"
}
};
res.send("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + xml(response));
});
});
router.get('/communities/:communityID', upload.none(), function (req, res) {
database.connect().then(async e => {
@@ -311,6 +267,48 @@ router.get('/communities/:communityID', upload.none(), function (req, res) {
});
router.get('/communities/:communityID/edit', upload.none(), function (req, res) {
database.connect().then(async e => {
//let paramPackData = util.data.decodeParamPack(req.headers["x-nintendo-parampack"]);
if(req.cookies.token === null)
{
res.redirect('/login');
return;
}
let pid = util.data.processServiceToken(req.cookies.token);
//console.log(req.headers["x-nintendo-servicetoken"]);
if(pid === null)
{
res.redirect('/login');
return;
}
let user = await database.getUserByPID(pid);
let community = await database.getCommunityByID(req.params.communityID.toString());
res.render('admin_edit_community.ejs', {
user: user,
community: community,
});
}).catch(error => {
console.log(error);
res.set("Content-Type", "application/xml");
res.statusCode = 400;
response = {
result: {
has_error: 1,
version: 1,
code: 400,
error_code: 15,
message: "SERVER_ERROR"
}
};
res.send("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + xml(response));
});
});
router.get('/users', upload.none(), function (req, res) {
database.connect().then(async e => {
@@ -352,6 +350,104 @@ router.get('/users', upload.none(), function (req, res) {
});
router.get('/users/:userID', upload.none(), function (req, res) {
database.connect().then(async e => {
if(req.cookies.token === null)
{
res.redirect('/login');
return;
}
let pid = util.data.processServiceToken(req.cookies.token);
if(pid === null)
{
res.redirect('/login');
return;
}
let user = await database.getUserByPID(req.params.userID);
let parentUser = await database.getUserByPID(pid)
if(user === null)
res.sendStatus(404);
let newPosts = await database.getNumberUserPostsByID(req.params.userID, 50);
let numPosts = await database.getTotalPostsByUserID(req.params.userID);
let communityMap = await util.data.getCommunityHash();
res.render('admin_user.ejs', {
communityMap: communityMap,
moment: moment,
parentUser: parentUser,
user: user,
newPosts: newPosts,
numPosts: numPosts,
});
}).catch(error => {
console.log(error);
res.set("Content-Type", "application/xml");
res.statusCode = 400;
response = {
result: {
has_error: 1,
version: 1,
code: 400,
error_code: 15,
message: "SERVER_ERROR"
}
};
res.send("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + xml(response));
});
});
router.get('/users/:userID/edit', upload.none(), function (req, res) {
database.connect().then(async e => {
if(req.cookies.token === null)
{
res.redirect('/login');
return;
}
let pid = util.data.processServiceToken(req.cookies.token);
if(pid === null)
{
res.redirect('/login');
return;
}
let user = await database.getUserByPID(req.params.userID);
let parentUser = await database.getUserByPID(pid)
if(user === null)
res.sendStatus(404);
let newPosts = await database.getNumberUserPostsByID(req.params.userID, 50);
let numPosts = await database.getTotalPostsByUserID(req.params.userID);
res.render('admin_edit_user.ejs', {
moment: moment,
parentUser: parentUser,
user: user,
newPosts: newPosts,
numPosts: numPosts,
});
}).catch(error => {
console.log(error);
res.set("Content-Type", "application/xml");
res.statusCode = 400;
response = {
result: {
has_error: 1,
version: 1,
code: 400,
error_code: 15,
message: "SERVER_ERROR"
}
};
res.send("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + xml(response));
});
});
router.get('/login', upload.none(), function (req, res) {
database.connect().then(async e => {
@@ -424,8 +520,11 @@ router.post('/login', upload.none(), function (req, res) {
let password = req.body.password;
if(user !== null && password !== null)
{
if(config.authorized_PNIDs.indexOf(user.pid) === -1)
if(config.authorized_PNIDs.indexOf(user.pid) === -1) {
logger.audit('[' + user.user_id + ' - ' + user.pid + '] is not authorized to access the application');
throw new Error('User is not authorized to access the application');
}
let password_hash = await util.data.nintendoPasswordHash(password, user.pid);
await request.post({
url: "http://" + config.account_server_domain + "/v1/api/oauth20/access_token/generate",
@@ -442,6 +541,7 @@ router.post('/login', upload.none(), function (req, res) {
}
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
logger.audit('[' + user.user_id + ' - ' + user.pid + '] signed into the application');
res.send(body);
}
else

View File

@@ -59,7 +59,9 @@ router.post('/new', upload.none(), async function (req, res, next) {
else
{
let usrObj = await database.getUserByPID(pid);
//let community_id = req.body.olive_title_id.substring(0, req.body.olive_title_id.indexOf(','));
if(usrObj.account_status !== 0) {
throw new Error('User not allowed to post')
}
let community = await database.getCommunityByID(req.body.olive_community_id);
let appData = "";
if (req.body.app_data) {

View File

@@ -21,7 +21,7 @@
</div>
<div class="right" style="background-color:#ddd;">
<h2>Posts</h2>
<h2>Audit Log</h2>
</div>
</div>

View File

@@ -64,48 +64,99 @@
</div>
<div class="community-page-posts-wrapper">
<% newPosts.forEach(function(post) { %>
<div class="post-user-info-wrapper">
<%if(post.verified) {%>
<img class="community-page-post-user-icon verified" src="<%= post.mii_face_url %>" onclick="loadUserProfile(<%=post.pid%>)">
<span class="community-page-verified-user-badge community-page-verified" style=""></span>
<%} else {%>
<img class="community-page-post-user-icon" src="<%= post.mii_face_url %>" onclick="loadUserProfile(<%=post.pid%>)">
<span class="community-page-verified-user-badge community-page-verified" style="display: none;"></span>
<%}%>
<h2 class="community-page-post-username" onclick="loadUserProfile(<%=post.pid%>)"><%= post.screen_name %></h2>
<h4 class="community-page-post-time-stamp"><%= post.created_at %></h4>
<div id="<%= post.id %>">
<div class="post-user-info-wrapper">
<%if(post.verified) {%>
<img class="community-page-post-user-icon verified" src="<%= post.mii_face_url %>" onclick="loadUserProfile(<%=post.pid%>)">
<span class="community-page-verified-user-badge community-page-verified" style=""></span>
<%} else {%>
<img class="community-page-post-user-icon" src="<%= post.mii_face_url %>" onclick="loadUserProfile(<%=post.pid%>)">
<span class="community-page-verified-user-badge community-page-verified" style="display: none;"></span>
<%}%>
<h2 class="community-page-post-username" onclick="loadUserProfile(<%=post.pid%>)"><%= post.screen_name %></h2>
<h4 class="community-page-post-time-stamp"><%= post.created_at %></h4>
<div class="community-page-post-yeah-button-wrapper">
<div class="community-page-post-yeah-button"></div>
</div>
<div id="yeah-<%= post.id %>" class="community-page-post-yeah-count"><%= post.empathy_count %> Yeahs</div>
</div>
<div class="community-page-post-wrapper">
<% if(post.body !== '' && post.painting === '' && post.screenshot === '' && !post.url) { %>
<h3><%= post.body %></h3>
<%} else { %>
<% if(post.screenshot !== '') { %>
<img id="<%= post.id %>" class="community-page-post-screenshot" src="data:image/png;base64,<%= post.screenshot %>">
<%}%>
<% if(post.painting !== '') { %>
<img id="<%= post.id%>" class="community-page-post-painting" src="<%= post.painting_uri %>">
<%}%>
<% if(post.url) { %>
<iframe width="760" height="427.5" src="<%= post.url %>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<%}%>
<% if(post.body) { %>
<div class="community-page-post-text-overlay">
<h3><%= post.body %></h3>
<div class="community-page-post-yeah-button-wrapper">
<div class="community-page-post-yeah-button" onclick="deletePost(event, '<%= post.id %>')"></div>
</div>
<%}%>
<%}%>
</div>
<br>
<br>
<div id="yeah-<%= post.id %>" class="community-page-post-yeah-count"><%= post.empathy_count %> Yeahs</div>
</div>
<div class="community-page-post-wrapper">
<% if(post.body !== '' && post.painting === '' && post.screenshot === '' && !post.url) { %>
<h3><%= post.body %></h3>
<%} else { %>
<% if(post.screenshot !== '') { %>
<img class="community-page-post-screenshot" src="data:image/png;base64,<%= post.screenshot %>">
<%}%>
<% if(post.painting !== '') { %>
<img class="community-page-post-painting" src="<%= post.painting_uri %>">
<%}%>
<% if(post.url) { %>
<iframe width="760" height="427.5" src="<%= post.url %>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<%}%>
<% if(post.body) { %>
<div class="community-page-post-text-overlay">
<h3><%= post.body %></h3>
</div>
<%}%>
<%}%>
</div>
</div>
<% }); %>
</div>
</div>
</div>
<script>
function deletePost(event, postID) {
if (event.shiftKey) {
var post = document.getElementById(postID);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
post.style.display = 'none';
}
else if (this.readyState === 4){
alert('Error: "' + this.statusText + '"\nPlease send code to Jemma on Discord with what you were doing');
}
};
xhttp.open("POST", "/v1/posts/" + postID + '/delete', true);
xhttp.send();
} else {
if(confirm('Delete post?')) {
var post = document.getElementById(postID);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
post.style.display = 'none';
}
else if (this.readyState === 4){
alert('Error: "' + this.statusText + '"\nPlease send code to Jemma on Discord with what you were doing');
}
};
xhttp.open("POST", "/v1/posts/" + postID + '/delete', true);
xhttp.send();
}
}
}
function loadUserPosts() {
var id = document.getElementsByClassName('post-user-info-wrapper')[document.getElementsByClassName('post-user-info-wrapper').length - 1].id
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
document.getElementsByClassName('community-page-posts-wrapper')[0].innerHTML += this.responseText;
}
else if(this.readyState === 4 && this.status === 204)
{
document.getElementById('load-more-posts-button').style.display = 'none';
}
else if (this.readyState === 4){
alert('Error: "' + this.statusText + '"\nPlease send code to Jemma on Discord with what you were doing');
}
};
xhttp.open("GET", "/users/loadPosts" + '?postID=' + id, true);
xhttp.send();
}
</script>
</body>
</html>

View File

@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Edit - <%= user.user_id %></title>
<link rel="stylesheet" type="text/css" href="/css/juxt.css">
</head>
<body>
<h2 style="display: inline-block; margin-left: 20px">Juxt Admin Panel - <%= parentUser.user_id %></h2> <img style="width: 57px; display: inline-block; position: absolute; right: 8px;" src="<%= parentUser.pfp_uri %>">
<div class="row">
<div class="left" style="background-color:#bbb;max-width: 10%;">
<ul id="myMenu">
<li><a href="/">Home</a></li>
<li><a href="/communities">Communities</a></li>
<li><a href="/audit">Audit Log</a></li>
<li><a href="/users">Users</a></li>
<li><a href="/discovery">Discovery</a></li>
</ul>
</div>
<div class="right" style="background-color:#ddd;">
<h2>Update <%= user.user_id %></h2>
<form action="/v1/users/<%= user.pid %>/update" enctype="multipart/form-data" target="formSubmitFrame" method="post">
<div class="form-section">
<div class="section-info">
<h2>Account Standing</h2>
</div>
<div class="section-inputs">
<div class="input-div choices-inputs">
Account Status
<input type="radio" id="account_status" name="account_status" value="0" <%if(user.account_status === 0) {%> checked <%}%>>
<label for="Fine">Fine</label>
<input type="radio" id="posting_limited" name="account_status" value="1" <%if(user.account_status === 1) {%> checked <%}%>>
<label for="posting_limited">Limited from Posting</label>
<input type="radio" id="temp_ban" name="account_status" value="2" <%if(user.account_status === 2) {%> checked <%}%>>
<label for="temp_ban">Temporary Ban</label>
<input type="radio" id="forever_ban" name="account_status" value="3" <%if(user.account_status === 3) {%> checked <%}%>>
<label for="forever_ban">Forever Ban</label>
</div>
<label for="ban_date">Banned Until:</label>
<input type="date" id="ban_date" name="ban_date" value="<%=moment(user.ban_lift_date).format('YYYY-MM-DD');%>">
<div class="input-div">
<label for="ban_reason">Ban reason:</label>
<textarea type="text" id="ban_reason" name="ban_reason"><%=user.ban_reason%></textarea>
</div>
</div>
</div>
<div class="form-section">
<div class="section-info">
<h2>Submit</h2>
<p></p>
</div>
<div class="section-inputs">
<div>
<button type="submit" class="btn">Submit</button>
</div>
<iframe name="formSubmitFrame"></iframe>
</div>
</div>
</form>
</div>
</div>
</body>
</html>

167
src/views/admin_user.ejs Normal file
View File

@@ -0,0 +1,167 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Juxt Admin Panel</title>
<link rel="stylesheet" type="text/css" href="/css/juxt.css">
</head>
<body>
<h2 style="display: inline-block; margin-left: 20px">Juxt Admin Panel - <%= parentUser.user_id %></h2> <img style="width: 57px; display: inline-block; position: absolute; right: 8px;" src="<%= parentUser.pfp_uri %>">
<div class="row">
<div class="left" style="background-color:#bbb;max-width: 10%;">
<ul id="myMenu">
<li><a href="/">Home</a></li>
<li><a href="/communities">Communities</a></li>
<li><a href="/audit">Audit Log</a></li>
<li><a href="/users">Users</a></li>
<li><a href="/discovery">Discovery</a></li>
</ul>
</div>
<div class="right" style="background-color:#ddd;">
<div class="community-page-info-container">
<img class="community-page-info-icon" src="<%= user.pfp_uri %>">
<h2 class="community-page-title"><%= user.user_id %></h2>
<h4 class="community-page-description"><%= user.profile_comment %></h4>
<button type="button" style="margin-left: 20px; width: 760px" onclick="window.location='/users/<%= user.pid %>/edit'">Edit</button>
<div class="community-page-margin-line"></div>
<table class="community-page-table-wrapper">
<tbody>
<tr>
<td>
<div class="community-page-shaded-info-container">
<h4 class="community-page-table-label">Country</h4>
<h4 class="community-page-table-text">N/A</h4>
</div>
</td>
<td>
<div class="community-page-shaded-info-container">
<h4 class="community-page-table-label">Birthday</h4>
<h4 class="community-page-table-text">N/A</h4>
</div>
</td>
<td>
<div class="community-page-shaded-info-container">
<h4 class="community-page-table-label">Game experience</h4>
<h4 class="community-page-table-text">
<%if(user.game_skill === 0) {%>
Beginner
<%} else if(user.game_skill === 1) {%>
Intermediate
<%} else if(user.game_skill === 2) {%>
Expert
<%} else {%>
N/A
<%}%>
</h4>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="community-page-posts-wrapper">
<% if(numPosts === 0) {%>
<p>No Posts</p>
<%} else { %>
<% newPosts.forEach(function(post) { %>
<div id="<%= post.id %>">
<div class="post-user-info-wrapper">
<%if(post.verified) {%>
<img class="community-page-post-user-icon verified" src="<%= post.mii_face_url %>" onclick="loadUserProfile(<%=post.pid%>)">
<span class="community-page-verified-user-badge community-page-verified" style=""></span>
<%} else {%>
<img class="community-page-post-user-icon" src="<%= post.mii_face_url %>" onclick="loadUserProfile(<%=post.pid%>)">
<span class="community-page-verified-user-badge community-page-verified" style="display: none;"></span>
<%}%>
<h2 class="community-page-post-username" onclick="loadUserProfile(<%=post.pid%>)"><%= post.screen_name %></h2>
<h4 class="community-page-post-time-stamp"><%= post.created_at %></h4>
<div class="community-page-post-yeah-button-wrapper">
<div class="community-page-post-yeah-button" onclick="deletePost(event, '<%= post.id %>')"></div>
</div>
<div id="yeah-<%= post.id %>" class="community-page-post-yeah-count"><%= post.empathy_count %> Yeahs</div>
</div>
<div class="community-page-post-wrapper">
<% if(post.body !== '' && post.painting === '' && post.screenshot === '' && !post.url) { %>
<h3><%= post.body %></h3>
<%} else { %>
<% if(post.screenshot !== '') { %>
<img class="community-page-post-screenshot" src="data:image/png;base64,<%= post.screenshot %>">
<%}%>
<% if(post.painting !== '') { %>
<img class="community-page-post-painting" src="<%= post.painting_uri %>">
<%}%>
<% if(post.url) { %>
<iframe width="760" height="427.5" src="<%= post.url %>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<%}%>
<% if(post.body) { %>
<div class="community-page-post-text-overlay">
<h3><%= post.body %></h3>
</div>
<%}%>
<%}%>
</div>
</div>
<% }); %>
<button id="load-more-posts-button" onclick="loadUserPosts()">Load More Posts</button>
<%}%>
</div>
</div>
</div>
<script>
function deletePost(event, postID) {
if (event.shiftKey) {
var post = document.getElementById(postID);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
post.style.display = 'none';
}
else if (this.readyState === 4){
alert('Error: "' + this.statusText + '"\nPlease send code to Jemma on Discord with what you were doing');
}
};
xhttp.open("POST", "/v1/posts/" + postID + '/delete', true);
xhttp.send();
} else {
if(confirm('Delete post?')) {
var post = document.getElementById(postID);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
post.style.display = 'none';
}
else if (this.readyState === 4){
alert('Error: "' + this.statusText + '"\nPlease send code to Jemma on Discord with what you were doing');
}
};
xhttp.open("POST", "/v1/posts/" + postID + '/delete', true);
xhttp.send();
}
}
}
function loadUserPosts() {
var id = document.getElementsByClassName('post-user-info-wrapper')[document.getElementsByClassName('post-user-info-wrapper').length - 1].id
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
document.getElementsByClassName('community-page-posts-wrapper')[0].innerHTML += this.responseText;
}
else if(this.readyState === 4 && this.status === 204)
{
document.getElementById('load-more-posts-button').style.display = 'none';
}
else if (this.readyState === 4){
alert('Error: "' + this.statusText + '"\nPlease send code to Jemma on Discord with what you were doing');
}
};
xhttp.open("GET", "/users/loadPosts" + '?postID=' + id, true);
xhttp.send();
}
</script>
</body>
</html>

View File

@@ -70,7 +70,7 @@
for(let i = 0; i < data.length; i++) {
body +=
'<tr id="' + data[i].pid + '" onclick="alert(this.id)">' +
'<tr id="' + data[i].pid + '" onclick="location.assign(\'/users/\' + this.id)">' +
'<td><img style="width: 80px " src="' + data[i].pfp_uri + '"></img></td>' +
'<td><a>' + data[i].user_id + '</a></td>' +
'<td>' + data[i].created_at + '</td>' +

View File

@@ -0,0 +1,12 @@
<script>
<%if(user.account_status === 1) {%>
wiiuErrorViewer.openByCodeAndMessage(5980009, '<%=user.user_id%> has been limited from posting until: \n\n<%= moment(user.ban_lift_date) %>.\n\nReason: <%=user.ban_reason%>\n\nIf you have any questions contact the developers in the Discord server.');
location.href = '/communities'
<%} else if(user.account_status === 2) {%>
wiiuErrorViewer.openByCodeAndMessage(5980010, '<%=user.user_id%> has been banned until: \n\n<%= moment(user.ban_lift_date) %>.\n\nReason: <%=user.ban_reason%>\n\nIf you have any questions contact the developers in the Discord server.');
wiiuBrowser.closeApplication();
<%} else if(user.account_status === 3) {%>
wiiuErrorViewer.openByCodeAndMessage(5980011, '<%=user.user_id%> has been banned forever.\n\nReason: <%=user.ban_reason%>\n\nIf you have any questions contact the developers in the Discord server.');
wiiuBrowser.closeApplication();
<%}%>
</script>

View File

@@ -130,7 +130,7 @@
<div class="community-page-header" style="background-image: url('<%= community.WiiU_browser_header %>')"></div>
<div class="community-page-header-overlay"></div>
<div class="community-page-back-button" onclick="window.history.back()"></div>
<div id="community-new-post-wrapper" <%if(user.pid === 1000000000) {%> style="display: none" <%}%>>
<div id="community-new-post-wrapper" <%if(user.pid === 1000000000 || user.account_status !== 0) {%> style="display: none" <%}%>>
<div class="new-post-button-text" onclick="showNewPostScreen()">
+ New Post
</div>

View File

@@ -103,7 +103,7 @@
<div class="community-page-header" style="background-image: url('<%= community.WiiU_browser_header %>')"></div>
<div class="community-page-header-overlay"></div>
<div class="community-page-back-button" onclick="window.history.back()"></div>
<div id="community-new-post-wrapper" <%if(user.pid === 1000000000) {%> style="display: none" <%}%>>
<div id="community-new-post-wrapper" <%if(user.pid === 1000000000 || user.account_status !== 0) {%> style="display: none" <%}%>>
<div class="new-post-button-text" onclick="showNewPostScreen()">
+ New Post
</div>