mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
feat: support Pricings flow (#2250)
* feat: fix price display * feat: support subscription * feat: fix select-plan-> signup -> buy-plan -> login flow * feat: support paid-user to login and jump to the pricing page * feat: support more subscription state * feat: add payment providers for plan * feat: format code * feat: gofumpt * feat: redirect to buy-plan-result page when user have pending subscription * feat: response err when pricing don't exit * Update PricingListPage.js * Update ProductBuyPage.js * Update LoginPage.js --------- Co-authored-by: hsluoyz <hsluoyz@qq.com>
This commit is contained in:
@ -133,7 +133,11 @@ class SignupPage extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
getResultPath(application) {
|
||||
getResultPath(application, signupParams) {
|
||||
if (signupParams?.plan && signupParams?.pricing) {
|
||||
// the prompt page needs the user to be signed in, so for paid-user sign up, just go to buy-plan page
|
||||
return `/buy-plan/${application.organization}/${signupParams?.pricing}?user=${signupParams.username}&plan=${signupParams.plan}`;
|
||||
}
|
||||
if (authConfig.appName === application.name) {
|
||||
return "/result";
|
||||
} else {
|
||||
@ -173,13 +177,13 @@ class SignupPage extends React.Component {
|
||||
const application = this.getApplicationObj();
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
values["plan"] = params.get("plan");
|
||||
values["pricing"] = params.get("pricing");
|
||||
values.plan = params.get("plan");
|
||||
values.pricing = params.get("pricing");
|
||||
|
||||
AuthBackend.signup(values)
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
if (Setting.hasPromptPage(application)) {
|
||||
if (Setting.hasPromptPage(application) && (!values.plan || !values.pricing)) {
|
||||
AuthBackend.getAccount("")
|
||||
.then((res) => {
|
||||
let account = null;
|
||||
@ -188,13 +192,13 @@ class SignupPage extends React.Component {
|
||||
account.organization = res.data2;
|
||||
|
||||
this.onUpdateAccount(account);
|
||||
Setting.goToLinkSoft(this, this.getResultPath(application));
|
||||
Setting.goToLinkSoft(this, this.getResultPath(application, values));
|
||||
} else {
|
||||
Setting.showMessage("error", `${i18next.t("application:Failed to sign in")}: ${res.msg}`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Setting.goToLinkSoft(this, this.getResultPath(application));
|
||||
Setting.goToLinkSoft(this, this.getResultPath(application, values));
|
||||
}
|
||||
} else {
|
||||
Setting.showMessage("error", i18next.t(`signup:${res.msg}`));
|
||||
|
Reference in New Issue
Block a user