@salesforce/ui-bundle-template-feature-vue-authentication 0.0.0-stage → 13.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +82 -0
- package/README.md +106 -2
- package/dist/.forceignore +15 -0
- package/dist/.husky/pre-commit +4 -0
- package/dist/.prettierignore +11 -0
- package/dist/.prettierrc +17 -0
- package/dist/CHANGELOG.md +5431 -0
- package/dist/README.md +83 -0
- package/dist/config/project-scratch-def.json +13 -0
- package/dist/eslint.config.js +7 -0
- package/dist/force-app/main/default/classes/UIBundleAuthUtils.cls +68 -0
- package/dist/force-app/main/default/classes/UIBundleAuthUtils.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleAuthUtils_Test.cls +141 -0
- package/dist/force-app/main/default/classes/UIBundleAuthUtils_Test.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleChangePassword.cls +77 -0
- package/dist/force-app/main/default/classes/UIBundleChangePassword.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleForgotPassword.cls +71 -0
- package/dist/force-app/main/default/classes/UIBundleForgotPassword.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleLogin.cls +105 -0
- package/dist/force-app/main/default/classes/UIBundleLogin.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleRegistration.cls +162 -0
- package/dist/force-app/main/default/classes/UIBundleRegistration.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleSocialLoginConfig.cls +145 -0
- package/dist/force-app/main/default/classes/UIBundleSocialLoginConfig.cls-meta.xml +5 -0
- package/dist/force-app/main/default/classes/UIBundleSocialLoginConfig_Test.cls +181 -0
- package/dist/force-app/main/default/classes/UIBundleSocialLoginConfig_Test.cls-meta.xml +5 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/.forceignore +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/.graphqlrc.yml +2 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/.prettierignore +9 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/.prettierrc +11 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/README.md +43 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/codegen.yml +95 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/components.json +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/e2e/app.spec.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/eslint.config.js +124 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/feature-vue-authentication.uibundle-meta.xml +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/index.html +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/package.json +74 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/playwright.config.ts +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/scripts/get-graphql-schema.mjs +71 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/scripts/rewrite-e2e-assets.mjs +23 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/App.vue +5 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/api/graphqlClient.ts +44 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/appLayout.vue +80 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/alerts/status-alert.vue +59 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/layouts/card-layout.vue +30 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/alert/Alert.vue +21 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/alert/AlertAction.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/alert/AlertDescription.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/alert/AlertTitle.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/alert/index.ts +25 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/avatar/Avatar.vue +23 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/avatar/AvatarFallback.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/avatar/AvatarImage.vue +16 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/avatar/index.ts +3 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/button/Button.vue +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/button/index.ts +43 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/Card.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardAction.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardContent.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardDescription.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardFooter.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardHeader.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/CardTitle.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/card/index.ts +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/checkbox/Checkbox.vue +43 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/checkbox/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/collapsible/Collapsible.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/collapsible/CollapsibleContent.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/collapsible/CollapsibleTrigger.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/collapsible/index.ts +3 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/Dialog.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogClose.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogContent.vue +59 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogDescription.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogFooter.vue +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogHeader.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogOverlay.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogPortal.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogTitle.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/DialogTrigger.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dialog/index.ts +10 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenu.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +51 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuContent.vue +47 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuGroup.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuItem.vue +44 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuLabel.vue +30 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuPortal.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +21 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +52 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuSeparator.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuShortcut.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuSub.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuSubContent.vue +37 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +38 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/DropdownMenuTrigger.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/dropdown-menu/index.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/Field.vue +27 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldContent.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldDescription.vue +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldError.vue +48 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldGroup.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldLabel.vue +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldLegend.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldSeparator.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldSet.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/FieldTitle.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/field/index.ts +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/index.ts +115 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/input/Input.vue +30 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/input/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/label/Label.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/label/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/Pagination.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationContent.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationEllipsis.vue +23 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationItem.vue +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationLink.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationNext.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/PaginationPrevious.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/pagination/index.ts +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/Popover.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverAnchor.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverContent.vue +44 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverDescription.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverHeader.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverTitle.vue +14 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/PopoverTrigger.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/popover/index.ts +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/Select.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectContent.vue +65 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectGroup.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectItem.vue +41 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectLabel.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectScrollDownButton.vue +32 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectScrollUpButton.vue +32 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectSeparator.vue +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectTrigger.vue +45 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/SelectValue.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/select/index.ts +10 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/separator/Separator.vue +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/separator/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/skeleton/Skeleton.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/skeleton/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/sonner/Sonner.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/sonner/index.ts +3 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/spinner/Spinner.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/components/ui/spinner/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/composables/useAsyncData.ts +69 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/api/userProfileApi.ts +107 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/authHelpers.ts +78 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/authenticationConfig.ts +66 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/components/SocialLogin.vue +150 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/composables/useCountdownTimer.ts +246 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/composables/useRetryWithBackoff.ts +112 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/composables/useSessionTimeout.ts +244 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/context/authContext.ts +115 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/footers/FooterLink.vue +47 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/forms/AuthForm.vue +141 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/forms/SubmitButton.vue +57 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/hooks/EmailField.vue +46 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/hooks/PasswordField.vue +48 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/hooks/TextField.vue +106 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/hooks/form.ts +90 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/hooks/formContexts.ts +61 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/layout/CenteredPageLayout.vue +76 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/layouts/AuthAppLayout.vue +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/layouts/PrivateRouteLayout.vue +50 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/menu/AuthMenu.vue +143 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/ChangePassword.vue +122 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/ForgotPassword.vue +90 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/Login.vue +106 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/Profile.vue +180 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/Register.vue +135 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/pages/ResetPassword.vue +114 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/sessionTimeout/SessionExpiredAlert.vue +50 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/sessionTimeout/SessionTimeoutValidator.vue +136 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/sessionTimeout/SessionWarningModal.vue +151 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/sessionTimeout/sessionTimeService.ts +142 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/sessionTimeout/sessionTimeoutConfig.ts +82 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/utils/helpers.ts +90 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/features/authentication/utils/queryToSearchParams.ts +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/lib/utils.ts +6 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/main.ts +6 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/pages/Home.vue +10 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/pages/NotFound.vue +18 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/router-utils.ts +32 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/router.ts +90 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/styles/global.css +134 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/src/test/setup.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/tsconfig.json +45 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/tsconfig.node.json +13 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/tsconfig.tsbuildinfo +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/ui-bundle.json +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/vite-env.d.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/vite.config.ts +106 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-authentication/vitest-env.d.ts +2 -0
- package/dist/jest.config.js +6 -0
- package/dist/package-lock.json +12554 -0
- package/dist/package.json +46 -0
- package/dist/scripts/apex/hello.apex +10 -0
- package/dist/scripts/gitignore-templates.json +4 -0
- package/dist/scripts/graphql-search.sh +191 -0
- package/dist/scripts/network-senders.mjs +84 -0
- package/dist/scripts/org-setup-config-schema.mjs +132 -0
- package/dist/scripts/org-setup-dev.mjs +114 -0
- package/dist/scripts/org-setup-url.mjs +108 -0
- package/dist/scripts/org-setup-utils.mjs +569 -0
- package/dist/scripts/org-setup-xml.mjs +283 -0
- package/dist/scripts/org-setup.config.json +5 -0
- package/dist/scripts/org-setup.mjs +2545 -0
- package/dist/scripts/sf-project-setup.mjs +103 -0
- package/dist/scripts/soql/account.soql +6 -0
- package/dist/scripts/validate-org-setup-config.mjs +38 -0
- package/dist/sfdx-project.json +12 -0
- package/package.json +44 -4
package/dist/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Salesforce DX Project: Next Steps
|
|
2
|
+
|
|
3
|
+
Now that you’ve created a Salesforce DX project, what’s next? Here are some documentation resources to get you started.
|
|
4
|
+
|
|
5
|
+
## Web app: install, build, and dev server
|
|
6
|
+
|
|
7
|
+
From the **SFDX project root** (this directory), run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run sf-project-setup
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This installs dependencies in the UI Bundle, builds it, and starts the Vite dev server. Use this after cloning or extracting the project.
|
|
14
|
+
|
|
15
|
+
## Set up the org
|
|
16
|
+
|
|
17
|
+
`npm run setup` configures a target org from this project in one command: it logs in
|
|
18
|
+
(a required precondition — auto-skipped if the org is already connected), deploys
|
|
19
|
+
metadata, assigns permission sets, imports sample data, refreshes the GraphQL
|
|
20
|
+
schema/types, and builds the UI Bundle. When `--target-org` is omitted it uses your
|
|
21
|
+
default org or, in an interactive terminal, prompts you to pick one.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm run setup -- --target-org <alias> # or omit --target-org to use the default / pick
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Before each Network deployment, setup reads the target org's existing sender
|
|
28
|
+
address and preserves it in the local metadata. Sender changes must be made in
|
|
29
|
+
the site's Administration settings. For a direct `sf project deploy` command,
|
|
30
|
+
first run `node scripts/network-senders.mjs --target-org <alias>` after generating
|
|
31
|
+
the project.
|
|
32
|
+
|
|
33
|
+
Setup does **not** start the dev server. Once the org is set up, use `dev:preview` to
|
|
34
|
+
refresh the GraphQL types against the org and launch the Vite dev server on its own:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm run dev:preview
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Setup configuration (`scripts/org-setup.config.json`)
|
|
41
|
+
|
|
42
|
+
`org-setup.config.json` controls which steps run and how. Every top-level section is
|
|
43
|
+
optional; an absent section hides its step. It is validated against a shared schema
|
|
44
|
+
at build/CI time and again at the start of every `npm run setup`, so a malformed
|
|
45
|
+
config fails fast rather than misbehaving.
|
|
46
|
+
|
|
47
|
+
```jsonc
|
|
48
|
+
{
|
|
49
|
+
"permsetAssignments": {
|
|
50
|
+
"assignments": {
|
|
51
|
+
"My_Access": { "assignee": "currentUser" }
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"role": { "assignee": "currentUser", "roleName": "Admin" },
|
|
55
|
+
"selfRegistration": {
|
|
56
|
+
"selfRegProfile": "My Prospect Profile",
|
|
57
|
+
"accountName": "My Self-Registration"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
When a `selfRegistration` section is present, setup runs a **license pre-check**
|
|
63
|
+
before configuring self-registration: it derives the required `UserLicense` from the
|
|
64
|
+
configured `selfRegProfile` (matched on the stable `LicenseDefinitionKey`, not the
|
|
65
|
+
display name) and, if the org lacks that license or has no available seats, **warns
|
|
66
|
+
and skips** self-registration instead of reporting success — so prospect login can't
|
|
67
|
+
silently fail on an under-provisioned org. No separate license field is configured;
|
|
68
|
+
the requirement always follows the profile the flow assigns.
|
|
69
|
+
|
|
70
|
+
## How Do You Plan to Deploy Your Changes?
|
|
71
|
+
|
|
72
|
+
Do you want to deploy a set of changes, or create a self-contained application? Choose a [development model](https://developer.salesforce.com/tools/vscode/en/user-guide/development-models).
|
|
73
|
+
|
|
74
|
+
## Configure Your Salesforce DX Project
|
|
75
|
+
|
|
76
|
+
The `sfdx-project.json` file contains useful configuration information for your project. See [Salesforce DX Project Configuration](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm) in the _Salesforce DX Developer Guide_ for details about this file.
|
|
77
|
+
|
|
78
|
+
## Read All About It
|
|
79
|
+
|
|
80
|
+
- [Salesforce Extensions Documentation](https://developer.salesforce.com/tools/vscode/)
|
|
81
|
+
- [Salesforce CLI Setup Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm)
|
|
82
|
+
- [Salesforce DX Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm)
|
|
83
|
+
- [Salesforce CLI Command Reference](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference.htm)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"orgName": "My Saleforce Org",
|
|
3
|
+
"edition": "Developer",
|
|
4
|
+
"features": ["EnableSetPasswordInApi"],
|
|
5
|
+
"settings": {
|
|
6
|
+
"lightningExperienceSettings": {
|
|
7
|
+
"enableS1DesktopEnabled": true
|
|
8
|
+
},
|
|
9
|
+
"mobileSettings": {
|
|
10
|
+
"enableS1EncryptedStoragePref2": false
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility class for Web Application authentication REST endpoints.
|
|
3
|
+
*/
|
|
4
|
+
public without sharing class UIBundleAuthUtils {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Exception for authentication errors with HTTP status code support.
|
|
8
|
+
*/
|
|
9
|
+
public class AuthException extends Exception {
|
|
10
|
+
public Integer statusCode { get; private set; } // HTTP status code (e.g. 400, 500)
|
|
11
|
+
public List<String> messages { get; private set; } // List of error messages
|
|
12
|
+
|
|
13
|
+
public AuthException(Integer statusCode, String message) {
|
|
14
|
+
this.statusCode = statusCode;
|
|
15
|
+
this.messages = new List<String>{ message };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public AuthException(Integer statusCode, List<String> messages) {
|
|
19
|
+
this.statusCode = statusCode;
|
|
20
|
+
this.messages = new List<String>(messages);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Validates and sanitizes redirect URL to prevent open redirect vulnerabilities.
|
|
26
|
+
* @param url The URL to validate.
|
|
27
|
+
* @param defaultUrl Fallback URL if validation fails.
|
|
28
|
+
* @return Sanitized URL or defaultUrl if invalid.
|
|
29
|
+
*/
|
|
30
|
+
public static String getSanitizedStartUrl(String url, String defaultUrl) {
|
|
31
|
+
if (String.isBlank(url) || url.equals('/')) { return defaultUrl; }
|
|
32
|
+
|
|
33
|
+
String decoded; // Decode URL to catch encoded bypasses (%2f%2f -> //)
|
|
34
|
+
try {
|
|
35
|
+
decoded = EncodingUtil.urlDecode(url, 'UTF-8');
|
|
36
|
+
} catch (Exception e) {
|
|
37
|
+
return defaultUrl;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Must start with / but not // (protocol-relative)
|
|
41
|
+
if (!decoded.startsWith('/') || decoded.startsWith('//')) { return defaultUrl; }
|
|
42
|
+
// Reject backslashes (some browsers treat \ as /)
|
|
43
|
+
if (decoded.contains('\\')) { return defaultUrl; }
|
|
44
|
+
// Reject @ which can indicate user info in URL (//user@evil.com)
|
|
45
|
+
if (decoded.contains('@')) { return defaultUrl; }
|
|
46
|
+
// Reject : which could indicate protocol or port manipulation
|
|
47
|
+
if (decoded.contains(':')) { return defaultUrl; }
|
|
48
|
+
// Reject control characters (ASCII < 32) and DEL (127)
|
|
49
|
+
for (Integer i = 0; i < decoded.length(); i++) {
|
|
50
|
+
Integer charCode = decoded.charAt(i);
|
|
51
|
+
if (charCode < 32 || charCode == 127) { return defaultUrl; }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return defaultUrl + url;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Logs an error message and stack trace to the system debug log.
|
|
59
|
+
* It is only captured if a Trace Flag is active for the user.
|
|
60
|
+
*
|
|
61
|
+
* @param ex The exception to log.
|
|
62
|
+
* @param level The logging level to use.
|
|
63
|
+
*/
|
|
64
|
+
public static void debugLog(Exception ex, LoggingLevel level) {
|
|
65
|
+
System.debug(level, 'Message: ' + ex.getMessage());
|
|
66
|
+
System.debug(level, 'Stack Trace: ' + ex.getStackTraceString());
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test class for UIBundleAuthUtils.
|
|
3
|
+
*
|
|
4
|
+
* Focuses on getSanitizedStartUrl, the shared open-redirect (CWE-601) guard
|
|
5
|
+
* used by UIBundleLogin, UIBundleRegistration and UIBundleSocialLoginConfig.
|
|
6
|
+
* Every rejection path and the safe-path prefixing
|
|
7
|
+
* behavior are asserted deterministically with an explicit path prefix.
|
|
8
|
+
*/
|
|
9
|
+
@isTest
|
|
10
|
+
private class UIBundleAuthUtils_Test {
|
|
11
|
+
|
|
12
|
+
// Explicit, non-null community path prefix so behavior is deterministic
|
|
13
|
+
// (Site.getPathPrefix() is null/blank in a plain unit-test context).
|
|
14
|
+
private static final String PREFIX = '/community';
|
|
15
|
+
|
|
16
|
+
// ---- Safe / allowed inputs ----------------------------------------------
|
|
17
|
+
|
|
18
|
+
@isTest
|
|
19
|
+
static void allowsSafeRelativePath() {
|
|
20
|
+
System.assertEquals(
|
|
21
|
+
'/community/dashboard',
|
|
22
|
+
UIBundleAuthUtils.getSanitizedStartUrl('/dashboard', PREFIX),
|
|
23
|
+
'A safe community-relative path should be prefixed and preserved'
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@isTest
|
|
28
|
+
static void allowsNestedRelativePath() {
|
|
29
|
+
System.assertEquals(
|
|
30
|
+
'/community/safe/relative/path',
|
|
31
|
+
UIBundleAuthUtils.getSanitizedStartUrl('/safe/relative/path', PREFIX),
|
|
32
|
+
'A nested relative path should be prefixed and preserved'
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@isTest
|
|
37
|
+
static void blankAndRootFallBackToDefault() {
|
|
38
|
+
System.assertEquals(PREFIX, UIBundleAuthUtils.getSanitizedStartUrl(null, PREFIX), 'null -> default');
|
|
39
|
+
System.assertEquals(PREFIX, UIBundleAuthUtils.getSanitizedStartUrl('', PREFIX), 'empty -> default');
|
|
40
|
+
System.assertEquals(PREFIX, UIBundleAuthUtils.getSanitizedStartUrl(' ', PREFIX), 'whitespace -> default');
|
|
41
|
+
System.assertEquals(PREFIX, UIBundleAuthUtils.getSanitizedStartUrl('/', PREFIX), '"/" -> default');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ---- Rejected / malicious inputs (all fall back to the default) ----------
|
|
45
|
+
|
|
46
|
+
@isTest
|
|
47
|
+
static void rejectsAbsoluteHttpUrl() {
|
|
48
|
+
System.assertEquals(
|
|
49
|
+
PREFIX,
|
|
50
|
+
UIBundleAuthUtils.getSanitizedStartUrl('https://evil-attacker.com', PREFIX),
|
|
51
|
+
'Absolute http(s) URL must be rejected'
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@isTest
|
|
56
|
+
static void rejectsProtocolRelativeUrl() {
|
|
57
|
+
System.assertEquals(
|
|
58
|
+
PREFIX,
|
|
59
|
+
UIBundleAuthUtils.getSanitizedStartUrl('//evil-attacker.com', PREFIX),
|
|
60
|
+
'Protocol-relative URL must be rejected'
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@isTest
|
|
65
|
+
static void rejectsAmbiguousScheme() {
|
|
66
|
+
System.assertEquals(
|
|
67
|
+
PREFIX,
|
|
68
|
+
UIBundleAuthUtils.getSanitizedStartUrl('https:evil-attacker.com', PREFIX),
|
|
69
|
+
'Malformed/ambiguous scheme must be rejected'
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@isTest
|
|
74
|
+
static void rejectsBackslashVariant() {
|
|
75
|
+
System.assertEquals(
|
|
76
|
+
PREFIX,
|
|
77
|
+
UIBundleAuthUtils.getSanitizedStartUrl('/\\evil-attacker.com', PREFIX),
|
|
78
|
+
'Backslash normalization trick must be rejected'
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@isTest
|
|
83
|
+
static void rejectsAtSign() {
|
|
84
|
+
System.assertEquals(
|
|
85
|
+
PREFIX,
|
|
86
|
+
UIBundleAuthUtils.getSanitizedStartUrl('/x@evil-attacker.com', PREFIX),
|
|
87
|
+
'User-info "@" must be rejected'
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@isTest
|
|
92
|
+
static void rejectsColon() {
|
|
93
|
+
System.assertEquals(
|
|
94
|
+
PREFIX,
|
|
95
|
+
UIBundleAuthUtils.getSanitizedStartUrl('/path:8080', PREFIX),
|
|
96
|
+
'Colon (port/scheme manipulation) must be rejected'
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@isTest
|
|
101
|
+
static void rejectsEncodedProtocolRelativeBypass() {
|
|
102
|
+
// %2f%2f decodes to // — the decode step must catch this.
|
|
103
|
+
System.assertEquals(
|
|
104
|
+
PREFIX,
|
|
105
|
+
UIBundleAuthUtils.getSanitizedStartUrl('%2f%2fevil-attacker.com', PREFIX),
|
|
106
|
+
'URL-encoded protocol-relative bypass must be rejected'
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@isTest
|
|
111
|
+
static void rejectsControlCharacters() {
|
|
112
|
+
String withNewline = '/foo' + String.fromCharArray(new List<Integer>{ 10 }) + 'bar';
|
|
113
|
+
System.assertEquals(
|
|
114
|
+
PREFIX,
|
|
115
|
+
UIBundleAuthUtils.getSanitizedStartUrl(withNewline, PREFIX),
|
|
116
|
+
'Embedded control characters must be rejected'
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ---- Supporting API coverage --------------------------------------------
|
|
121
|
+
|
|
122
|
+
@isTest
|
|
123
|
+
static void authExceptionCarriesStatusAndMessages() {
|
|
124
|
+
UIBundleAuthUtils.AuthException single = new UIBundleAuthUtils.AuthException(400, 'bad request');
|
|
125
|
+
System.assertEquals(400, single.statusCode, 'statusCode should round-trip');
|
|
126
|
+
System.assertEquals(1, single.messages.size(), 'single-message constructor');
|
|
127
|
+
|
|
128
|
+
UIBundleAuthUtils.AuthException multi =
|
|
129
|
+
new UIBundleAuthUtils.AuthException(500, new List<String>{ 'a', 'b' });
|
|
130
|
+
System.assertEquals(500, multi.statusCode, 'statusCode should round-trip');
|
|
131
|
+
System.assertEquals(2, multi.messages.size(), 'multi-message constructor');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@isTest
|
|
135
|
+
static void debugLogCompletesWithoutError() {
|
|
136
|
+
Test.startTest();
|
|
137
|
+
UIBundleAuthUtils.debugLog(new IllegalArgumentException('boom'), LoggingLevel.ERROR);
|
|
138
|
+
Test.stopTest();
|
|
139
|
+
System.assert(true, 'debugLog should complete without throwing');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Applications REST endpoint for authenticated user password changes.
|
|
3
|
+
*
|
|
4
|
+
* Endpoint: POST /services/apexrest/auth/change-password
|
|
5
|
+
*
|
|
6
|
+
* Allows authenticated users to change their password by providing their current password
|
|
7
|
+
* and a new password. The new password is validated against org password policies.
|
|
8
|
+
*
|
|
9
|
+
* Security: Uses 'with sharing' to enforce user-level security. Only authenticated users
|
|
10
|
+
* can change their own password.
|
|
11
|
+
*/
|
|
12
|
+
@RestResource(urlMapping='/auth/change-password')
|
|
13
|
+
global with sharing class UIBundleChangePassword {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Changes the password for the currently authenticated user.
|
|
17
|
+
*
|
|
18
|
+
* @param newPassword The new password to set.
|
|
19
|
+
* @param currentPassword The user's current password for verification.
|
|
20
|
+
* @return SuccessPasswordChangeResponse on success, ErrorPasswordChangeResponse on failure.
|
|
21
|
+
*/
|
|
22
|
+
@HttpPost
|
|
23
|
+
global static PasswordChangeResponse changePassword(String newPassword, String currentPassword) {
|
|
24
|
+
Savepoint sp = Database.setSavepoint();
|
|
25
|
+
try {
|
|
26
|
+
// newPassword and confirmPassword should be validated to be the same value on the client
|
|
27
|
+
Site.changePassword(newPassword, newPassword, currentPassword);
|
|
28
|
+
return new SuccessPasswordChangeResponse();
|
|
29
|
+
} catch (Exception ex) {
|
|
30
|
+
Database.rollback(sp);
|
|
31
|
+
|
|
32
|
+
// System.SecurityException is a user error but treat others as system errors
|
|
33
|
+
if (ex instanceof System.SecurityException) {
|
|
34
|
+
RestContext.response.statusCode = 400;
|
|
35
|
+
return new ErrorPasswordChangeResponse(ex.getMessage());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Logs are only captured if a Trace Flag is active for the user
|
|
39
|
+
UIBundleAuthUtils.debugLog(ex, LoggingLevel.ERROR);
|
|
40
|
+
|
|
41
|
+
RestContext.response.statusCode = 500;
|
|
42
|
+
return new ErrorPasswordChangeResponse('Password change failed');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Base response class for password change operations. */
|
|
47
|
+
global abstract class PasswordChangeResponse {
|
|
48
|
+
|
|
49
|
+
/** Success or failure of the password change operation */
|
|
50
|
+
protected final Boolean success;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Success response for password change. */
|
|
54
|
+
global class SuccessPasswordChangeResponse extends PasswordChangeResponse {
|
|
55
|
+
|
|
56
|
+
/** Constructs a success response. */
|
|
57
|
+
private SuccessPasswordChangeResponse() {
|
|
58
|
+
this.success = true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Error response for password change. */
|
|
63
|
+
global class ErrorPasswordChangeResponse extends PasswordChangeResponse {
|
|
64
|
+
|
|
65
|
+
/** Error message describing the failure reason */
|
|
66
|
+
private final String error;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Constructs an error response with the specified error message.
|
|
70
|
+
* @param error The error message to return to the client.
|
|
71
|
+
*/
|
|
72
|
+
private ErrorPasswordChangeResponse(String error) {
|
|
73
|
+
this.success = false;
|
|
74
|
+
this.error = error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST endpoint for Web Applications forgot password functionality.
|
|
3
|
+
*
|
|
4
|
+
* Endpoint: POST /services/apexrest/auth/forgot-password
|
|
5
|
+
*
|
|
6
|
+
* Sends a password reset email to the user's registered email address.
|
|
7
|
+
*/
|
|
8
|
+
@RestResource(urlMapping='/auth/forgot-password')
|
|
9
|
+
global with sharing class UIBundleForgotPassword {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Initiates the forgot password process by sending a reset email.
|
|
13
|
+
* @param email User's email address (used as username).
|
|
14
|
+
* @return ForgotPasswordResponse with success status or error message.
|
|
15
|
+
*/
|
|
16
|
+
@HttpPost
|
|
17
|
+
global static ForgotPasswordResponse forgotPassword(String username) {
|
|
18
|
+
try {
|
|
19
|
+
username = username.trim().toLowerCase();
|
|
20
|
+
|
|
21
|
+
if (String.isBlank(username)) {
|
|
22
|
+
RestContext.response.statusCode = 400;
|
|
23
|
+
return new ErrorForgotPasswordResponse('Username is required.');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// [Dev Note] This will send a password reset link to the user's email address
|
|
27
|
+
// if the username exists.
|
|
28
|
+
Site.forgotPassword(username);
|
|
29
|
+
|
|
30
|
+
return new SuccessForgotPasswordResponse();
|
|
31
|
+
} catch (Exception ex) {
|
|
32
|
+
// Logs are only captured if a Trace Flag is active for the user
|
|
33
|
+
UIBundleAuthUtils.debugLog(ex, LoggingLevel.ERROR);
|
|
34
|
+
|
|
35
|
+
RestContext.response.statusCode = 500;
|
|
36
|
+
return new ErrorForgotPasswordResponse('Could not send password reset link.');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Base response class for forgot password operations. */
|
|
41
|
+
global abstract class ForgotPasswordResponse {
|
|
42
|
+
|
|
43
|
+
/** Success or failure of the forgot password operation */
|
|
44
|
+
protected final Boolean success;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Success response for forgot password. */
|
|
48
|
+
global class SuccessForgotPasswordResponse extends ForgotPasswordResponse {
|
|
49
|
+
|
|
50
|
+
/** Constructs a success response. */
|
|
51
|
+
private SuccessForgotPasswordResponse() {
|
|
52
|
+
this.success = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Error response for forgot password. */
|
|
57
|
+
global class ErrorForgotPasswordResponse extends ForgotPasswordResponse {
|
|
58
|
+
|
|
59
|
+
/** Error message describing the failure reason */
|
|
60
|
+
private final String error;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Constructs an error response with the specified error message.
|
|
64
|
+
* @param error The error message to return to the client.
|
|
65
|
+
*/
|
|
66
|
+
private ErrorForgotPasswordResponse(String error) {
|
|
67
|
+
this.success = false;
|
|
68
|
+
this.error = error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST endpoint for Web Applications user login.
|
|
3
|
+
*
|
|
4
|
+
* Endpoint: POST /services/apexrest/auth/login
|
|
5
|
+
*
|
|
6
|
+
* Authenticates a user and returns a redirect URL for session creation.
|
|
7
|
+
*
|
|
8
|
+
* @see https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_sites.htm#apex_System_Site_login
|
|
9
|
+
*/
|
|
10
|
+
@RestResource(urlMapping='/auth/login')
|
|
11
|
+
global with sharing class UIBundleLogin {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Authenticates a user and returns a redirect URL.
|
|
15
|
+
* @param email User's email address (used as username).
|
|
16
|
+
* @param password User's password.
|
|
17
|
+
* @param startUrl Optional URL to redirect to after login.
|
|
18
|
+
* @return LoginResponse with redirectUrl on success, or error message on failure.
|
|
19
|
+
*/
|
|
20
|
+
@HttpPost
|
|
21
|
+
global static LoginResponse doLogin(String email, String password, String startUrl) {
|
|
22
|
+
try {
|
|
23
|
+
validateInput(email, password);
|
|
24
|
+
|
|
25
|
+
String username = email.trim().toLowerCase();
|
|
26
|
+
String sanitizedStartUrl = UIBundleAuthUtils.getSanitizedStartUrl(startUrl, Site.getPathPrefix());
|
|
27
|
+
|
|
28
|
+
PageReference loginResult;
|
|
29
|
+
try {
|
|
30
|
+
loginResult = Site.login(username, password, sanitizedStartUrl);
|
|
31
|
+
} catch (Exception loginEx) {
|
|
32
|
+
RestContext.response.statusCode = 400;
|
|
33
|
+
return new ErrorLoginResponse('Invalid username or password.');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (loginResult != null) {
|
|
37
|
+
return new SuccessLoginResponse(loginResult.getUrl());
|
|
38
|
+
} else {
|
|
39
|
+
RestContext.response.statusCode = 401;
|
|
40
|
+
return new ErrorLoginResponse(
|
|
41
|
+
'Your login attempt has failed. Make sure the username and password are correct.'
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
} catch (UIBundleAuthUtils.AuthException ex) {
|
|
45
|
+
RestContext.response.statusCode = ex.statusCode;
|
|
46
|
+
return new ErrorLoginResponse(ex.messages);
|
|
47
|
+
} catch (Exception ex) {
|
|
48
|
+
UIBundleAuthUtils.debugLog(ex, LoggingLevel.ERROR);
|
|
49
|
+
RestContext.response.statusCode = 500;
|
|
50
|
+
return new ErrorLoginResponse('An unexpected error occurred. Please contact your administrator.');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Validates login input fields.
|
|
56
|
+
* @param email The email to validate.
|
|
57
|
+
* @param password The password to validate.
|
|
58
|
+
* @throws UIBundleAuthUtils.AuthException if validation fails.
|
|
59
|
+
*/
|
|
60
|
+
private static void validateInput(String email, String password) {
|
|
61
|
+
List<String> errors = new List<String>();
|
|
62
|
+
if (String.isBlank(email)) {
|
|
63
|
+
errors.add('Email is required.');
|
|
64
|
+
}
|
|
65
|
+
if (String.isBlank(password)) {
|
|
66
|
+
errors.add('Password is required.');
|
|
67
|
+
}
|
|
68
|
+
if (!errors.isEmpty()) {
|
|
69
|
+
throw new UIBundleAuthUtils.AuthException(400, errors);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Base response class for login.
|
|
75
|
+
*/
|
|
76
|
+
global abstract class LoginResponse {
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Success response with redirect URL.
|
|
81
|
+
*/
|
|
82
|
+
global class SuccessLoginResponse extends LoginResponse {
|
|
83
|
+
global Boolean success = true;
|
|
84
|
+
global String redirectUrl;
|
|
85
|
+
|
|
86
|
+
global SuccessLoginResponse(String redirectUrl) {
|
|
87
|
+
this.redirectUrl = redirectUrl;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Error response with error messages.
|
|
93
|
+
*/
|
|
94
|
+
global class ErrorLoginResponse extends LoginResponse {
|
|
95
|
+
global List<String> errors;
|
|
96
|
+
|
|
97
|
+
global ErrorLoginResponse(List<String> errors) {
|
|
98
|
+
this.errors = new List<String>(errors);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
global ErrorLoginResponse(String error) {
|
|
102
|
+
this.errors = new List<String>{ error };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|