oops
This commit is contained in:
parent
f21a9515f4
commit
6e8874e3b0
|
@ -81,6 +81,7 @@ export async function upgradeUser(userId: T.UUID, subscription?: T.StripeSubscri
|
||||||
|
|
||||||
export async function downgradeUser(userId: T.UUID, subscriptionId?: string): Promise<T.DowngradeUserResponse> {
|
export async function downgradeUser(userId: T.UUID, subscriptionId?: string): Promise<T.DowngradeUserResponse> {
|
||||||
await deleteCouchDbAuthUser(userId);
|
await deleteCouchDbAuthUser(userId);
|
||||||
|
console.log("in function downgrading user with subscriptionId", subscriptionId);
|
||||||
if (subscriptionId) {
|
if (subscriptionId) {
|
||||||
stripe.subscriptions.del(subscriptionId);
|
stripe.subscriptions.del(subscriptionId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,6 +196,8 @@ const authRouter = (passport: PassportStatic) => {
|
||||||
if (!req.user) {
|
if (!req.user) {
|
||||||
return res.redirect("/");
|
return res.redirect("/");
|
||||||
}
|
}
|
||||||
|
// @ts-ignore;
|
||||||
|
console.log("will downgrade user with subscription id", req.user?.subscription?.id)
|
||||||
await downgradeUser(req.user.userId, "subscription" in req.user
|
await downgradeUser(req.user.userId, "subscription" in req.user
|
||||||
? req.user.subscription?.id
|
? req.user.subscription?.id
|
||||||
: undefined);
|
: undefined);
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if (user.tester && user.level === "student" && user.subscription) { %>
|
<% if (user.tester && user.level === "student" && user.subscription) { %>
|
||||||
<p>Current subscription: <% if (user.subscription.metadata.cycle === "monthly") { %>$1/month<% } else { %>$10/year<% } %></p>
|
<p>Current subscription: <% if (user.subscription.metadata.cycle === "monthly") { %>$1/month<% } else { %>$10/year<% } %></p>
|
||||||
<p><a href="#" onclick="handleDowngrade()">Downgrade</a> your account to cancel your subscription</p>
|
<p><a href="#" onclick="handleDowngrade()">Downgrade</a> to cancel your subscription</p>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if (user.email) { %>
|
<% if (user.email) { %>
|
||||||
<h4 class="mt-3 mb-3">Password <i class="fas fa-key ml-2"></i></h4>
|
<h4 class="mt-3 mb-3">Password <i class="fas fa-key ml-2"></i></h4>
|
||||||
|
@ -228,12 +228,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function handleDowngrade() {
|
function handleDowngrade() {
|
||||||
const answer = confirm("Are you sure you want to downgrade your account? Your wordlist will be deleted forever. (Export it to CSV from the dictionary if you want to keep it)");
|
const answer = confirm("Are you sure you want to downgrade your account? Your wordlist will be deleted forever. (Export it to CSV from the dictionary first if you want to keep it.)");
|
||||||
if (answer) {
|
if (answer) {
|
||||||
fetch("/downgradeToBasic", { method: "POST" }).then((res) => res.json()).then((res) => {
|
fetch("/downgradeToBasic", { method: "POST" }).then((res) => res.json()).then((res) => {
|
||||||
if (res.ok) {
|
|
||||||
window.location = "/";
|
window.location = "/";
|
||||||
}
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
alert("Error downgrading account - check your connection");
|
alert("Error downgrading account - check your connection");
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
Loading…
Reference in New Issue