chore: fix indents and address nitpicks

This commit is contained in:
Jemma
2024-06-01 16:29:36 -05:00
parent f8bb78fd51
commit 94904be12d
5 changed files with 155 additions and 153 deletions

View File

@@ -49,7 +49,7 @@ input[type="submit"] {
min-height: 60px;
text-align: center;
font-size: 28px;
background: -webkit-gradient(linear, left top, left bottom, from(#FFF), color-stop(0.5, #FFF), color-stop(0.8, #F6F6F6), color-stop(0.95, #F5F5F5), to(#BBB))0 0;
background: -webkit-gradient(linear, left top, left bottom, from(#FFF), color-stop(0.5, #FFF), color-stop(0.8, #F6F6F6), color-stop(0.95, #F5F5F5), to(#BBB)) 0 0;
border-radius: 12px;
cursor: pointer;
border: 0;
@@ -117,11 +117,11 @@ div.group > select {
cursor: pointer;
}
div.group > span {
color: #000;
}
div.group > svg {
}
div.group > svg {
fill: #9D6FF3;
border: none;
height: 40px;
@@ -131,7 +131,7 @@ div.group > span {
padding: 0px;
margin-bottom: -10px;
margin-left: 5px;
}
}
.account-info {
float: left;
@@ -247,8 +247,7 @@ div.radio label {
-webkit-box-align: center;
-webkit-box-pack: center;
text-align: center;
background: -webkit-gradient(linear, left top, left bottom, from(#FFF), color-stop(0.5, #FFF), color-stop(0.8, #F6F6F6), color-stop(0.95, #F5F5F5), to(#BBB))0 0;
border-radius: 12px;
background: -webkit-gradient(linear, left top, left bottom, from(#FFF), color-stop(0.5, #FFF), color-stop(0.8, #F6F6F6), color-stop(0.95, #F5F5F5), to(#BBB)) 0 0;
cursor: pointer;
border: 0;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
@@ -289,7 +288,7 @@ input[type="submit"] {
height: 85px;
line-height: 100px;
padding: 0 40px 0 60px;
background: -webkit-gradient(linear, left top, left bottom, from(#FFF), color-stop(0.5, #FFF), to(#E6E6E6))0 0;
background: -webkit-gradient(linear, left top, left bottom, from(#FFF), color-stop(0.5, #FFF), to(#E6E6E6)) 0 0;
font-size: 28px;
z-index: 20;
border-radius: 40px 0 0 0;

View File

@@ -21,7 +21,7 @@ import settings from '@/services/nnas/routes/account-settings';
// * Router to handle the subdomain restriction
const nnas = express.Router();
// Static routes for the user information app
// * Static routes for the user information app
async function setCSSHeader(request: express.Request, response: express.Response, next: express.NextFunction): Promise<void> {
response.set('Content-Type', 'text/css');
return next();

View File

@@ -16,7 +16,7 @@ import { Country, Region } from '@/types/services/nnas/regions';
import timezones from '@/services/nnas/timezones.json';
import regionsList from '@/services/nnas/regions.json';
const router: express.Router = express.Router();
const router = express.Router();
const accountSettingsSchema = z.object({
gender: z.enum(['M', 'F']),
@@ -36,13 +36,15 @@ const accountSettingsSchema = z.object({
*/
router.get('/ui/profile', async function (request: express.Request, response: express.Response): Promise<void> {
const server: HydratedServerDocument | null = await getServerByClientID('3f3928cc6f780638d360f0485cef973f', config.server_environment);
const token: string | undefined = getValueFromHeaders(request.headers, 'x-nintendo-service-token');
const token = getValueFromHeaders(request.headers, 'x-nintendo-service-token');
if (!server || !token) {
response.sendStatus(504);
return;
}
const aes_key: string = server?.aes_key;
const decryptedToken: Buffer = decryptToken(Buffer.from(token, 'base64'), aes_key);
const decryptedToken = decryptToken(Buffer.from(token, 'base64'), aes_key);
const tokenContents: Token = unpackToken(decryptedToken);
@@ -54,8 +56,8 @@ router.get('/ui/profile', async function (request: express.Request, response: ex
return;
}
const countryCode: string = PNID.country;
const language: string = PNID.language;
const countryCode = PNID.country;
const language = PNID.language;
const regionLanguages: RegionLanguages = timezones[countryCode as keyof typeof timezones];
const regionTimezones: RegionTimezones = regionLanguages[language] ? regionLanguages[language] : Object.values(regionLanguages)[0];
@@ -65,9 +67,9 @@ router.get('/ui/profile', async function (request: express.Request, response: ex
const miiFaces = ['normal_face', 'smile_open_mouth', 'sorrow', 'surprise_open_mouth', 'wink_left', 'frustrated'];
const face = miiFaces[crypto.randomInt(5)];
const notice: string | undefined = request.query.notice ? request.query.notice.toString() : undefined;
const notice = request.query.notice ? request.query.notice.toString() : undefined;
const accountLevel: string[] = ['Standard', 'Tester', 'Moderator', 'Developer'];
const accountLevel = ['Standard', 'Tester', 'Moderator', 'Developer'];
response.render('index.ejs', {
PNID,
@@ -78,8 +80,7 @@ router.get('/ui/profile', async function (request: express.Request, response: ex
regions: region ? region.regions: [],
regionsList
});
}
catch (error: any) {
} catch (error: any) {
LOG_ERROR(error);
response.sendStatus(504);
return;
@@ -97,7 +98,9 @@ router.get('/mii/:pid/:face', async function (request: express.Request, response
response.sendStatus(404);
return;
}
const miiImage: Buffer = await got(`${config.cdn.base_url}/mii/${request.params.pid}/${request.params.face}.png`).buffer();
const miiImage = await got(`${config.cdn.base_url}/mii/${request.params.pid}/${request.params.face}.png`).buffer();
response.set('Content-Type', 'image/png');
response.send(miiImage);
});
@@ -108,15 +111,15 @@ router.get('/mii/:pid/:face', async function (request: express.Request, response
*/
router.post('/update', async function (request: express.Request, response: express.Response): Promise<void> {
const server: HydratedServerDocument | null = await getServerByClientID('3f3928cc6f780638d360f0485cef973f', config.server_environment);
const token: string | undefined = getValueFromHeaders(request.headers, 'x-nintendo-service-token');
const token = getValueFromHeaders(request.headers, 'x-nintendo-service-token');
if (!server || !token) {
response.sendStatus(504);
return;
}
const aesKey: string = server?.aes_key;
const decryptedToken: Buffer = decryptToken(Buffer.from(token, 'base64'), aesKey);
const aesKey = server?.aes_key;
const decryptedToken = decryptToken(Buffer.from(token, 'base64'), aesKey);
const tokenContents: Token = unpackToken(decryptedToken);
try {
@@ -137,7 +140,7 @@ router.post('/update', async function (request: express.Request, response: expre
return;
}
const timezoneName: string = (person.data.tz_name && !!Object.keys(person.data.tz_name).length) ? person.data.tz_name : pnid.timezone.name;
const timezoneName = (person.data.tz_name && !!Object.keys(person.data.tz_name).length) ? person.data.tz_name : pnid.timezone.name;
const regionLanguages: RegionLanguages = timezones[pnid.country as keyof typeof timezones];
const regionTimezones: RegionTimezones = regionLanguages[pnid.language] ? regionLanguages[pnid.language] : Object.values(regionLanguages)[0];
@@ -152,7 +155,7 @@ router.post('/update', async function (request: express.Request, response: expre
}
const regionObject: Region | undefined = country.regions.find((region) => region.id === person.data.region);
const region: number = regionObject ? regionObject.id : pnid.region;
const region = regionObject ? regionObject.id : pnid.region;
if (!timezone) {
response.status(404);
@@ -169,7 +172,7 @@ router.post('/update', async function (request: express.Request, response: expre
pnid.flags.off_device = person.data.off_device_flag;
if (person.data.server_selection) {
const environment: string = person.data.server_selection;
const environment = person.data.server_selection;
if (environment === 'test' && pnid.access_level < 1) {
response.status(400);

View File

@@ -47,4 +47,4 @@ export interface Config {
secret_key: string;
};
server_environment: string;
}
}

View File

@@ -2,96 +2,96 @@
<html lang="en">
<head>
<title>Account Settings</title>
<link rel="stylesheet" type="text/css" href="/v1/account-settings/css/index.css">
</head>
<body>
<form action=" /v1/account-settings/update" method="post">
<header>
<h1>Pretendo Network ID Settings</h1>
<button id="close" class="fixed-bottom-button left" onclick="wiiuBrowser.jumpToBaristaAccount();">Close</button>
<input id="save" class="fixed-bottom-button" type="submit" value="Submit">
</header>
<div class="account-info">
<img src="/v1/account-settings/mii/<%= PNID.pid %>/<%= face %>">
<h2 class="content"><%= PNID.mii.name %></h2>
<h3 class="content"><%= PNID.username %></h3>
<h3 class="content">
<% if (PNID.access_level === -1) { %>
<p class="tier-name access-level-banned">Banned</p>
<% } else if (PNID.connections.stripe.tier_level) { %>
<p class="tier-name tier-level-<%= PNID.connections.stripe.tier_level %>"><%= PNID.connections.stripe.tier_name %></p>
<% } else { %>
<p class="tier-name access-level-<%= PNID.access_level %>"><%= accountLevel[PNID.access_level] %></p>
<% } %>
</h3>
</div>
<div class="body-content">
<h1>User Settings</h1>
<div class="group">
<h2>Birth Date</h2>
<p class="content"><%= PNID.birthdate %></p>
</div>
<div class="group">
<h2>Gender</h2>
<select name="gender" id="gender">
<option value="M" <% if (PNID.gender === 'M') { %>selected<% } %>>Male</option>
<option value="F" <% if (PNID.gender === 'F') { %>selected<% } %>>Female</option>
</select>
</div>
<div class="group">
<h2>Country</h2>
<title>Account Settings</title>
<link rel="stylesheet" type="text/css" href="/v1/account-settings/css/index.css">
</head>
<body>
<form action=" /v1/account-settings/update" method="post">
<header>
<h1>Pretendo Network ID Settings</h1>
<button id="close" class="fixed-bottom-button left" onclick="wiiuBrowser.jumpToBaristaAccount();">Close</button>
<input id="save" class="fixed-bottom-button" type="submit" value="Submit">
</header>
<div class="account-info">
<img src="/v1/account-settings/mii/<%= PNID.pid %>/<%= face %>">
<h2 class="content"><%= PNID.mii.name %></h2>
<h3 class="content"><%= PNID.username %></h3>
<h3 class="content">
<% if (PNID.access_level === -1) { %>
<p class="tier-name access-level-banned">Banned</p>
<% } else if (PNID.connections.stripe.tier_level) { %>
<p class="tier-name tier-level-<%= PNID.connections.stripe.tier_level %>"><%= PNID.connections.stripe.tier_name %></p>
<% } else { %>
<p class="tier-name access-level-<%= PNID.access_level %>"><%= accountLevel[PNID.access_level] %></p>
<% } %>
</h3>
</div>
<div class="body-content">
<h1>User Settings</h1>
<div class="group">
<h2>Birth Date</h2>
<p class="content"><%= PNID.birthdate %></p>
</div>
<div class="group">
<h2>Gender</h2>
<select name="gender" id="gender">
<option value="M" <% if (PNID.gender === 'M') { %>selected<% } %>>Male</option>
<option value="F" <% if (PNID.gender === 'F') { %>selected<% } %>>Female</option>
</select>
</div>
<div class="group">
<h2>Country</h2>
<select name="country" id="country" onclick="warning()">
<% for (let region of regionsList) { %>
<option value="<%= region.iso_code %>" <% if (PNID.country === region.iso_code) { %>selected<% } %>><%= region.name %></option>
<% } %>
</select>
</div>
<div class="group">
<h2>Region</h2>
<select name="region" id="region">
<% for (let region of regions) { %>
<option value="<%= region.id %>" <% if (PNID.region === region.id) { %>selected<% } %>><%= region.name %></option>
<% } %>
</select>
</div>
<div class="group">
<h2>Timezone</h2>
<select name="tz_name" id="gender">
<% for (let timezone of regionTimezones) { %>
<option value="<%= timezone.area %>" <% if (PNID.timezone.name === timezone.area) { %>selected<% } %>><%= timezone.area %></option>
<% } %>
</select>
</div>
<h1>Email</h1>
<div class="group">
<input name="email" type="text" class="content" value="<%= PNID.email.address %>"></input>
</div>
<div class="group">
<% if(PNID.email.validated) { %>
<span>Verified</span>
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 256 256"><path d="M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"></path></svg>
<% } else { %>
<span>Email Not Verified</span>
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 256 256"><path d="M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"></path></svg>
<% } %>
</div>
<h1>Other Settings</h1>
<div class="group">
<h2>Server Environment</h2>
<div class="radio server-selection" id="server">
<input type="radio" id="prod" name="server_selection" value="prod" <% if (PNID.server_access_level === 'prod') { %>checked=""<% } %>>
<label for="prod">
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
<polyline points="7.5 4.21 12 6.81 16.5 4.21"></polyline>
<polyline points="7.5 19.79 7.5 14.6 3 12"></polyline>
<polyline points="21 12 16.5 14.6 16.5 19.79"></polyline>
<polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
<line x1="12" y1="22.08" x2="12" y2="12"></line>
</svg>
<h2>Production</h2>
</label>
<% for (let region of regionsList) { %>
<option value="<%= region.iso_code %>" <% if (PNID.country === region.iso_code) { %>selected<% } %>><%= region.name %></option>
<% } %>
</select>
</div>
<div class="group">
<h2>Region</h2>
<select name="region" id="region">
<% for (let region of regions) { %>
<option value="<%= region.id %>" <% if (PNID.region === region.id) { %>selected<% } %>><%= region.name %></option>
<% } %>
</select>
</div>
<div class="group">
<h2>Timezone</h2>
<select name="tz_name" id="gender">
<% for (let timezone of regionTimezones) { %>
<option value="<%= timezone.area %>" <% if (PNID.timezone.name === timezone.area) { %>selected<% } %>><%= timezone.area %></option>
<% } %>
</select>
</div>
<h1>Email</h1>
<div class="group">
<input name="email" type="text" class="content" value="<%= PNID.email.address %>"></input>
</div>
<div class="group">
<% if(PNID.email.validated) { %>
<span>Verified</span>
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 256 256"><path d="M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"></path></svg>
<% } else { %>
<span>Email Not Verified</span>
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 256 256"><path d="M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"></path></svg>
<% } %>
</div>
<h1>Other Settings</h1>
<div class="group">
<h2>Server Environment</h2>
<div class="radio server-selection" id="server">
<input type="radio" id="prod" name="server_selection" value="prod" <% if (PNID.server_access_level === 'prod') { %>checked=""<% } %>>
<label for="prod">
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
<polyline points="7.5 4.21 12 6.81 16.5 4.21"></polyline>
<polyline points="7.5 19.79 7.5 14.6 3 12"></polyline>
<polyline points="21 12 16.5 14.6 16.5 19.79"></polyline>
<polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
<line x1="12" y1="22.08" x2="12" y2="12"></line>
</svg>
<h2>Production</h2>
</label>
<% if(PNID.access_level >= 1) { %>
<input type="radio" id="beta" name="server_selection" value="test" <% if (PNID.server_access_level === 'test') { %> checked="" <% } %> <% if(PNID.access_level < 1) { %> disabled <% } %> >
<label for="beta">
@@ -110,49 +110,49 @@
<h2>Dev</h2>
</label>
<% } %>
</div>
</div>
<div class="group">
<h2>Email Notifications</h2>
<div class="radio server-selection" id="server">
<input type="radio" id="true" name="marketing_flag" value="true" <% if (PNID.flags.marketing) { %>checked=""<% } %>>
<label for="marketing_flag">
<h2>Receive</h2>
</label>
<input type="radio" id="false" name="marketing_flag" value="false" <% if (!PNID.flags.marketing) { %>checked=""<% } %>>
<label for="marketing_flag">
<h2>Do Not Receive</h2>
</label>
</div>
</div>
<div class="group">
<h2>Non-Nintendo Device Setting</h2>
<div class="radio server-selection" id="server">
<input type="radio" id="true" name="off_device_flag" value="true" <% if (PNID.flags.off_device) { %>checked=""<% } %>>
<label for="off_device_flag">
<h2>Allow</h2>
</label>
<input type="radio" id="false" name="off_device_flag" value="false" <% if (!PNID.flags.off_device) { %>checked=""<% } %>>
<label for="off_device_flag">
<h2>Deny</h2>
</label>
</div>
</div>
</div>
</form>
<% if (notice) { %>
<script>
wiiuDialog.alert('<%= notice %>', 'OK');
</script>
<% } %>
</div>
</div>
<div class="group">
<h2>Email Notifications</h2>
<div class="radio server-selection" id="server">
<input type="radio" id="true" name="marketing_flag" value="true" <% if (PNID.flags.marketing) { %>checked=""<% } %>>
<label for="marketing_flag">
<h2>Receive</h2>
</label>
<input type="radio" id="false" name="marketing_flag" value="false" <% if (!PNID.flags.marketing) { %>checked=""<% } %>>
<label for="marketing_flag">
<h2>Do Not Receive</h2>
</label>
</div>
</div>
<div class="group">
<h2>Non-Nintendo Device Setting</h2>
<div class="radio server-selection" id="server">
<input type="radio" id="true" name="off_device_flag" value="true" <% if (PNID.flags.off_device) { %>checked=""<% } %>>
<label for="off_device_flag">
<h2>Allow</h2>
</label>
<input type="radio" id="false" name="off_device_flag" value="false" <% if (!PNID.flags.off_device) { %>checked=""<% } %>>
<label for="off_device_flag">
<h2>Deny</h2>
</label>
</div>
</div>
</div>
</form>
<% if (notice) { %>
<script>
wiiuDialog.alert('<%= notice %>', 'OK');
</script>
<% } %>
<script>
var seen = false;
function warning() {
if(seen) return;
seen = true;
wiiuDialog.alert('Warning: Changing your country may cause unexpected results. You may need to re-link your PNID for the changes to apply. \n\nFor more information, see:\nhttps://pretendo.network/docs/errors/PAS-727-0001', 'I Understand');
wiiuDialog.alert('Warning: Changing your country may cause unexpected results. You may need to re-link your PNID for the changes to apply. \n\nFor more information, see:\nhttps://preten.do/PAS-727-0001', 'I Understand');
}
</script>
</body>
</body>
</html>