You've already forked AstralRinth
forked from didirus/AstralRinth
Billing / plus frontend (#2130)
* [wip] initial * [wip] subscriptions/plus frontend * [wip] finish payment flow * Charges page * finish most subscriptions work * Finish * update eslint * Fix issues * fix intl extract * fix omorphia locale extract * fix responsiveness * fix lint
This commit is contained in:
@@ -39,6 +39,16 @@ export const initAuth = async (oldToken = null) => {
|
||||
authCookie.value = route.query.code;
|
||||
}
|
||||
|
||||
if (route.fullPath.includes("new_account=true") && route.path !== "/auth/welcome") {
|
||||
const redirect = route.path.startsWith("/auth/") ? null : route.fullPath;
|
||||
|
||||
await navigateTo(
|
||||
`/auth/welcome?authToken=${route.query.code}${
|
||||
redirect ? `&redirect=${encodeURIComponent(redirect)}` : ""
|
||||
}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (authCookie.value) {
|
||||
auth.token = authCookie.value;
|
||||
|
||||
|
||||
6
apps/frontend/src/composables/country.js
Normal file
6
apps/frontend/src/composables/country.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export const useUserCountry = () =>
|
||||
useState("userCountry", () => {
|
||||
const headers = useRequestHeaders(["cf-ipcountry"]);
|
||||
|
||||
return headers["cf-ipcountry"] ?? "US";
|
||||
});
|
||||
@@ -12,20 +12,27 @@ export const initUser = async () => {
|
||||
const auth = (await useAuth()).value;
|
||||
|
||||
const user = {
|
||||
notifications: [],
|
||||
collections: [],
|
||||
follows: [],
|
||||
subscriptions: [],
|
||||
lastUpdated: 0,
|
||||
};
|
||||
|
||||
if (auth.user && auth.user.id) {
|
||||
try {
|
||||
const [follows, collections] = await Promise.all([
|
||||
useBaseFetch(`user/${auth.user.id}/follows`),
|
||||
useBaseFetch(`user/${auth.user.id}/collections`, { apiVersion: 3 }),
|
||||
const headers = {
|
||||
Authorization: auth.token,
|
||||
};
|
||||
|
||||
const [follows, collections, subscriptions] = await Promise.all([
|
||||
useBaseFetch(`user/${auth.user.id}/follows`, { headers }, true),
|
||||
useBaseFetch(`user/${auth.user.id}/collections`, { apiVersion: 3, headers }, true),
|
||||
useBaseFetch(`billing/subscriptions`, { internal: true, headers }, true),
|
||||
]);
|
||||
|
||||
user.collections = collections;
|
||||
user.follows = follows;
|
||||
user.subscriptions = subscriptions;
|
||||
user.lastUpdated = Date.now();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
@@ -170,6 +177,5 @@ export const logout = async () => {
|
||||
|
||||
await useAuth("none");
|
||||
useCookie("auth-token").value = null;
|
||||
await navigateTo("/");
|
||||
stopLoading();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user