Add a Guard for PDP/PLP pages - sap-commerce-cloud

I am trying to write an AuthGuard where any user trying to access any of the PDP/PLP pages is verified for credit issues before access. I believe I have to use the OOTB "ProductDetailsPageModule" and customize it
but the AuthGuard does not load on clicking on the navbar PDP links. Any suggestions?
I can use the following to manually activate the ProductGuard but how do I activate it on click of Product pages in Navbar?
{
path: 'test2',
component: MyCustomComponentForError,
canActivate: [CmsPageGuard, ProductGuard]},

Related

Show different routes to user than actual in angular

I am working on a full stack web development using Angular, Node(Express) and mySQL. I want to show user some different route than what it actually is. How can I do that?
For example, this is my dashboard page.
http://localhost:4200/#/dashboard
I want it to be viewed as something else to the user like:
http://localhost:4200/#/Welcome
OR
http://localhost:4200/#/Welcome/LandingPage
Meaning, this page can only be accessed if you enter the Url:
http://localhost:4200/#/dashboard
and, if the user tries to access this page by entering the Url that is being shown to him:
http://localhost:4200/#/Welcome
OR
http://localhost:4200/#/Welcome/LandingPage
then, he gets an error.
I have done this all in app.routing.ts. I just want to ask how can I do the above mentioned. To show that route to the user that actually doesn't exist.
For further clarification: When the user will open the page then it will be shown to him as "localhost:4200/#/Welcome". I want to just show the user this route. In my code, it actually should remain dashboard. In easy words, when the user enters the url: "localhost:4200/#/Welcome" it should throw an error because in code such route doesn't exist. It was just shown to the user as a kind of fake route. In actual, it should be "localhost:4200/#/dashboard" but, shows to user as "localhost:4200/#/Welcome"
I guess maybe using location will do the trick if I understood question right.
constructor(private location: Location){}
replaceState(){
this.location.replaceState("/Welcome");
}
You will have to import Location module:
import {Location} from '#angular/common';

How can I customize Yesod Login page?

I implemented Google authentication in my Yesod application.
When I open http://localhost:3000/auth/login I see a page generated by Yesod.
I tried to add login.hamlet to templates folder but it didn't override default login page.
Which is the right way to customize login page in Yesod?
You can override the classes methods listed here https://www.stackage.org/package/yesod-auth
For example if you want to change the default email login page, you can do in Foundation.hs
instance YesodAuthEmail App where
...
emailLoginHandler = myEmailLoginHandler
and then look here to see how to implement it https://www.stackage.org/haddock/nightly-2019-08-26/yesod-auth-1.6.7/src/Yesod.Auth.Email.html#defaultEmailLoginHandler

How to update index page content of shopify store using API like we are update other pages content using shopify admin API

I am developing shopify public app. I just want to know that can I get store home page content for upadte and add new content there.
I am getting all pages details and it contents by using shopify admin API for get page,create page,update page and delete page
like here we use following path for update particular page with page_id
PUT /admin/api/2019-04/pages/#{page_id}.json
{
"page": {
"id": 131092082,
"body_html": "<p>Returns accepted if we receive the items 14 days after purchase.</p>"
}
}
I had details of all static pages but i don't know how to update home page details like this
Can any one please help me that how I can get home page content and update that content using API or refer me any admin API to get this. Thank you
The smart way to do this is as follows. In the theme itself, you can tell when you are on the index page since Shopify renders index.liquid. In there, you can make a callback to your App using the App Proxy. The App then provides custom data as JSON or perhaps even Liquid. So the index page can now render with your App being part of the cycle.
That is probably the best pattern for you to work with for your specifics.
Finally got the solution to update index.liquid page of shopify store as follow
First you have to get themes by following
GET https://shop_domain/admin/api/2019-04/themes.json
This API give you thmes.json which contains all themes details used in this store.
Now you have to get theme_id from theme.json for update particular page by theme_id.
Update asset API for update content of index page
URL for update assets by theme_id
PUT https://shop_domain/admin/api/2019-04/themes/#{theme_id}/assets.json
require body for update API
{
"asset": {
"key": "templates/index.liquid",
"value": "add your content"
}
}
And this will update index page content with your content . It work successfully for me Thank you

Buildfire: Redirect a page to another plugin deeplink url

I like to redirect a page(e.g. login page) to another plugin using the deeplink url? Like for example during login, I want to redirect the user to the other page using the deeplink that is setup in the Control.
Like:
window.location.replace('deeplink url')
I am using the buildfire navigateTo, but don't know how to get the pluginId and instanceId, since it is not provided in the marketplace or in the myplugins section, there is not way to get it manually.
Here is my code:
buildfire.navigation.navigateTo({
pluginId: '',
instanceId: '',
title: 'Dashboard',
folderName: 'Dashboard',
});
How to get the pluginId or InstanceId of a certain plugin?
Is pluginId or instanceId is the license key of a custom plugin?
Do I need to use pluginInstance to set the plugin data and pass it to the navigateTo?

Orchard - How to understand if I'm calling from Admin panel

I need to execute some code everytime I load a page, except if the page belongs to the admin panel. I created an IActionFilter and in the OnActionExecuting method I tried to check for the Controller name, but it isn't an optimal solution because there are a lot of different controllers being called from the dashboard. Is there a more efficient way to recognize if I'm loading a page of the admin panel?
Yes there is
using Orchard.UI.Admin;
&
if (AdminFilter.IsApplied(filterContext.RequestContext))
{
// This is an admin page, do nothing
return;
}

Resources