Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(saas): support to configure the redirection url for site after login/signup #2302

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dashboard/src2/pages/saas/LoginToSite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ export default {
method: 'get_login_sid',
onSuccess(data) {
let sid = data;
let loginURL = `https://${this.$resources.siteRequest.doc.site}/desk?sid=${sid}`;
let redirectRoute =
this.$resources?.saasProduct?.doc?.redirect_to_after_login ??
'/desk';
let loginURL = `https://${this.$resources.siteRequest.doc.site}${redirectRoute}?sid=${sid}`;
this.isRedirectingToSite = true;
window.open(loginURL, '_self');
}
Expand Down
1 change: 1 addition & 0 deletions press/saas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ It has 2 doctypes.
}
```
- **Create Additional System User** [only for **manual** mode] - If this is checked, we will add an additional system user with the team's information after creating a new site.
- **Redirect To After Login** - After SaaS signup/login, user is directly logged-in to his site. By default, we redirect the user to desk of site. With this option, we can configure the redirect path. For example, for gameplan the path would be `/g`

#### FC Dashboard
- UI/UX - The pages are available in https://github.com/frappe/press/tree/master/dashboard/src2/pages/saas
Expand Down
12 changes: 10 additions & 2 deletions press/saas/doctype/product_trial/product_trial.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
"email_header_content",
"setup_wizard_tab",
"setup_wizard_completion_mode",
"setup_wizard_payload_generator_script",
"create_additional_system_user",
"setup_wizard_payload_generator_script"
"redirect_to_after_login"
],
"fields": [
{
Expand Down Expand Up @@ -217,6 +218,13 @@
"fieldname": "create_additional_system_user",
"fieldtype": "Check",
"label": "Create Additional System User"
},
{
"default": "/desk",
"fieldname": "redirect_to_after_login",
"fieldtype": "Data",
"label": "Redirect To After Login",
"reqd": 1
}
],
"image_field": "logo",
Expand All @@ -231,7 +239,7 @@
"link_fieldname": "product_trial"
}
],
"modified": "2024-11-19 16:12:29.471858",
"modified": "2024-11-21 22:13:33.724250",
"modified_by": "Administrator",
"module": "SaaS",
"name": "Product Trial",
Expand Down
5 changes: 5 additions & 0 deletions press/saas/doctype/product_trial/product_trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ProductTrial(Document):
enable_pooling: DF.Check
logo: DF.AttachImage | None
published: DF.Check
redirect_to_after_login: DF.Data
release_group: DF.Link
setup_wizard_completion_mode: DF.Literal["manual", "auto"]
setup_wizard_payload_generator_script: DF.Code | None
Expand All @@ -56,6 +57,7 @@ class ProductTrial(Document):
"domain",
"trial_days",
"trial_plan",
"redirect_to_after_login",
)

USER_LOGIN_PASSWORD_FIELD = "user_login_password"
Expand Down Expand Up @@ -100,6 +102,9 @@ def validate(self):
if field.fieldtype != "Password":
frappe.throw(f"{self.USER_LOGIN_PASSWORD_FIELD} field should be of type Password")

if not self.redirect_to_after_login.startswith("/"):
frappe.throw("Redirection route after login should start with /")

def setup_trial_site(self, team, plan, cluster=None, account_request=None):
from press.press.doctype.site.site import get_plan_config

Expand Down
Loading