final touchups
This commit is contained in:
parent
18bd140614
commit
6d2a264295
|
@ -144,7 +144,7 @@ apiRouter.post("/user/upgradeToStudentRequest", async (req, res, next) => {
|
||||||
if (!req.user) throw new Error("user not found");
|
if (!req.user) throw new Error("user not found");
|
||||||
try {
|
try {
|
||||||
if (req.user.level === "student" || req.user.level === "editor") {
|
if (req.user.level === "student" || req.user.level === "editor") {
|
||||||
res.send({ ok: true, message: "user already upgraded "});
|
res.send({ ok: true, message: "user already upgraded" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendUpgradeRequestToAdmin(req.user).catch(console.error);
|
sendUpgradeRequestToAdmin(req.user).catch(console.error);
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
<title>Account · LingDocs</title>
|
<title>Account · LingDocs</title>
|
||||||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" crossorigin="anonymous">
|
||||||
|
<script>
|
||||||
|
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container" style="max-width: 400px;">
|
<div class="container" style="max-width: 400px;">
|
||||||
|
@ -14,7 +17,7 @@
|
||||||
<% if (user.admin) { %>
|
<% if (user.admin) { %>
|
||||||
<a href="/admin"><h5 class="mb-2">Admin Console</h5></a>
|
<a href="/admin"><h5 class="mb-2">Admin Console</h5></a>
|
||||||
<% } %>
|
<% } %>
|
||||||
<h4>Profile:</h4>
|
<h4>Profile <i class="fas fa-user ml-2"></i></h4>
|
||||||
<form method="POST" class="mb-4">
|
<form method="POST" class="mb-4">
|
||||||
<div>
|
<div>
|
||||||
<label for="email" class="form-label">Email:</label>
|
<label for="email" class="form-label">Email:</label>
|
||||||
|
@ -48,9 +51,16 @@
|
||||||
<button type="submit" class="btn btn-primary">Update Profile</button>
|
<button type="submit" class="btn btn-primary">Update Profile</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<h5>Account Level: <%= user.level %></h5>
|
<h5>Account Level: <%= user.level.charAt(0).toUpperCase() + user.level.slice(1) %></h5>
|
||||||
|
<% if (user.level === "basic") { %>
|
||||||
|
<% if (user.upgradeToStudentRequest === "waiting") { %>
|
||||||
|
<p>Wating for upgrade approval</p>
|
||||||
|
<% } else { %>
|
||||||
|
<button class="btn btn-sm btn-secondary" id="upgrade-request-button" onclick="handleRequestUpgrade()">Request Upgrade</button>
|
||||||
|
<% } %>
|
||||||
|
<% } %>
|
||||||
<% if (user.email) { %>
|
<% if (user.email) { %>
|
||||||
<h4 class="mt-3">Password:</h4>
|
<h4 class="mt-3 mb-3">Password <i class="fas fa-key ml-2"></i></h4>
|
||||||
<% if (!user.password) { %>
|
<% if (!user.password) { %>
|
||||||
<p class="small">Add a password to be able to log in with just your e-mail address.</p>
|
<p class="small">Add a password to be able to log in with just your e-mail address.</p>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@ -81,7 +91,7 @@
|
||||||
<div id="password-change-result" style="display: none;" class="alert alert-info mt-3 mb-4" role="alert">
|
<div id="password-change-result" style="display: none;" class="alert alert-info mt-3 mb-4" role="alert">
|
||||||
</div>
|
</div>
|
||||||
<% if (user.email) { %>
|
<% if (user.email) { %>
|
||||||
<div class="d-flex flex-row justify-content-between mt-4 mb-3">
|
<div class="d-flex flex-row justify-content-between mt-2 mb-1">
|
||||||
<button type="button" id="password-change-button" class="btn btn-secondary">
|
<button type="button" id="password-change-button" class="btn btn-secondary">
|
||||||
<% if (user.password) { %>
|
<% if (user.password) { %>
|
||||||
Change
|
Change
|
||||||
|
@ -93,14 +103,14 @@
|
||||||
<button type="button" style="display: none;" id="cancel-password-change-button" class="btn btn-light">Cancel</button>
|
<button type="button" style="display: none;" id="cancel-password-change-button" class="btn btn-light">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<h4 class="mb-2">Linked Accounts:</h4>
|
<h4 class="mt-3 mb-1">Linked Accounts <i class="fas fa-link ml-2"></i></h4>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<% if (user.google) { %>
|
<% if (user.google) { %>
|
||||||
<!-- TODO: MAKE THIS EMAIL THING SAFER! -->
|
<!-- TODO: MAKE THIS EMAIL THING SAFER! -->
|
||||||
<div class="my-2 w-100 btn btn-secondary"><i class="fab fa-google mr-2"></i> Linked to Google · <%= user.google.emails[0].value %></div>
|
<div class="my-2 w-100 btn btn-secondary"><i class="fab fa-google mr-2"></i> Linked to Google · <%= user.google.emails[0].value %></div>
|
||||||
<form action="/google/remove" method="POST">
|
<form action="/google/remove" method="POST">
|
||||||
<% if (removeProviderOption) { %>
|
<% if (removeProviderOption) { %>
|
||||||
<button type="submit" class="btn btn-sm">Unlink from Google</button>
|
<button type="submit" class="btn btn-sm btn-outline">Unlink from Google</button>
|
||||||
<% } %>
|
<% } %>
|
||||||
</form>
|
</form>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@ -108,7 +118,7 @@
|
||||||
<div class="my-2 w-100 btn btn-secondary"><i class="fab fa-twitter mr-2"></i> Linked to Twitter · @<%= user.twitter.username %></div>
|
<div class="my-2 w-100 btn btn-secondary"><i class="fab fa-twitter mr-2"></i> Linked to Twitter · @<%= user.twitter.username %></div>
|
||||||
<form action="/twitter/remove" method="POST">
|
<form action="/twitter/remove" method="POST">
|
||||||
<% if (removeProviderOption) { %>
|
<% if (removeProviderOption) { %>
|
||||||
<button type="submit" class="btn btn-sm">Unlink from twitter</button>
|
<button type="submit" class="btn btn-sm btn-outline">Unlink from Twitter</button>
|
||||||
<% } %>
|
<% } %>
|
||||||
</form>
|
</form>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@ -116,7 +126,7 @@
|
||||||
<div class="my-2 w-100 btn btn-secondary"><i class="fab fa-github mr-2"></i> Linked to GitHub · <%= user.github.username %></div>
|
<div class="my-2 w-100 btn btn-secondary"><i class="fab fa-github mr-2"></i> Linked to GitHub · <%= user.github.username %></div>
|
||||||
<form action="/github/remove" method="POST">
|
<form action="/github/remove" method="POST">
|
||||||
<% if (removeProviderOption) { %>
|
<% if (removeProviderOption) { %>
|
||||||
<button type="submit" class="btn btn-sm">Unlink from GitHub</button>
|
<button type="submit" class="btn btn-sm btn-outline">Unlink from GitHub</button>
|
||||||
<% } %>
|
<% } %>
|
||||||
</form>
|
</form>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@ -147,8 +157,34 @@
|
||||||
<script>
|
<script>
|
||||||
if (window.opener) {
|
if (window.opener) {
|
||||||
const w = window.opener
|
const w = window.opener
|
||||||
w.postMessage("signed in", "https://dev.dictionary.lingdocs.com");
|
try {
|
||||||
// window.opener.postMessage("signed in", "https://dictionary.lingdocs.com");
|
w.postMessage("signed in", "https://dictionary.lingdocs.com");
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
w.postMessage("signed in", "https://dev.dictionary.lingdocs.com");
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function handleRequestUpgrade() {
|
||||||
|
console.log("got here");
|
||||||
|
const btn = document.getElementById("upgrade-request-button");
|
||||||
|
btn.innerHTML = "Sending...";
|
||||||
|
fetch("/api/user/upgradeToStudentRequest", {
|
||||||
|
method: "POST",
|
||||||
|
}).then((res) => res.json()).then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
if (res.ok) {
|
||||||
|
btn.innerHTML = "Upgrade request sent";
|
||||||
|
} else {
|
||||||
|
btn.innerHTML = "Error requesting upgrade";
|
||||||
|
}
|
||||||
|
}).catch((e) => {
|
||||||
|
console.error(e);
|
||||||
|
btn.innerHTML = "Error requesting upgrade";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
function clearPasswordForm() {
|
function clearPasswordForm() {
|
||||||
document.getElementById("oldPassword").value = "";
|
document.getElementById("oldPassword").value = "";
|
||||||
|
|
|
@ -160,7 +160,7 @@ const Account = ({ user, loadUser }: { user: AT.LingdocsUser | undefined, loadUs
|
||||||
: ""}</li>
|
: ""}</li>
|
||||||
<li className="list-group-item">Signs in with:
|
<li className="list-group-item">Signs in with:
|
||||||
{(user.password && user.email) && <span>
|
{(user.password && user.email) && <span>
|
||||||
<i className="fas fa-key ml-2"></i> <span className="small mr-2">Password</span>
|
<i className="fas fa-key ml-2"></i> <span className="small mr-1">Password</span>
|
||||||
</span>}
|
</span>}
|
||||||
{providers.map((provider) => (
|
{providers.map((provider) => (
|
||||||
user[provider] && <span>
|
user[provider] && <span>
|
||||||
|
@ -171,6 +171,7 @@ const Account = ({ user, loadUser }: { user: AT.LingdocsUser | undefined, loadUs
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{user.level === "student" && <p><strong>Note:</strong> If you had a student account in the previous system <em>your wordlist will be moved over to this account in a couple of days</em>.</p>}
|
||||||
<h4 className="mb-3">Account Admin</h4>
|
<h4 className="mb-3">Account Admin</h4>
|
||||||
<div className="row mb-4">
|
<div className="row mb-4">
|
||||||
{user.level === "basic" && <div className="col-sm mb-3">
|
{user.level === "basic" && <div className="col-sm mb-3">
|
||||||
|
|
Loading…
Reference in New Issue