How to check if a window.open instance goes to a different url - window

I want to schedule code to run when the user navigates to a different url in my window.open instance. This is for an api. How can I check when the users navigates to another url in order to run my code?

Related

Intercepting external redirections with Cypress

Here is my test scenario:
The user opens a page in my application, fills in some details in a form, and then clicks the button in the form.
A third-party library triggers a redirect to an external website to validate some information. After the validation is complete (this validation takes place in a single page), the script on the external site redirects the user back to my application with a custom URL.
I know that what I described above is similar to an oauth flow, but for something different.
So I know that it is not possible to test external websites with Cypress. As a workaround, I am thinking of intercepting the redirect that is triggered by the button click and manually processing the external site with cy.request. But I am getting nowhere with intercepting the redirect after the button click event. How can I use cy.intercept to get the URL that is requested after the button is clicked?
The second question is that the page I will be working on with 'cy.request' redirects to my app with a custom URL. So I need to intercept this redirect as well to continue testing with the relevant page in my app.

Laravel 6 Prevent restricted actions which are registered after logout

I'm using laravel/ui for authentication, let's say i opened my website in two separate tabs.
After i logout from one tab, if i click let's say delete blog button on other tab,
it takes me to login page as i'm using auth middleware, after which if i login and my delete action runs.
How to prevent this, i only want delete action to run when user is logged in and in the above case, after user logs in, i don't want to perform delete action straight away, user needs to click delete button again.
There are several solutions:
The best practice would be to change the delete request type to POST. Check here how to correctly use HTTP methods
In your Auth middleware, always redirect the user to some landing page.
I would strongly advise changing the request type. Once, I had to help to restore an IT system where some smart arse ran script to follow all links in an internal website and fetch all pages. Delete operations were implemented with the GET method.

Using a Controller and Restcontroller to allow users to access any page

I am using Spring Framework to build a webapp. I have a restcontroller that verifies the user (Google oAuth) and sends responses to the page to determine if the user is valid. There is another page on the site, however, called storage. If the user wanted to go straight to mysite.com/storage. How would I send the user to that page? I tried having a regular controller to direct the user there but I get a circular path error. What is the right practice here? Am I missing anything? Thanks. let me know if you need more information.

Google URL Shortener calls shortened URL by creation

I am trying to shorten a really long URL with the Google API. This URL contains some information about a User of a program, and if clicked, there happens some magic on the server, and the magic should only happen if the user itself has clicked the Link.
Now if I shorten a Link with the Google-URL-Shortener, Google automatically calls that Link which lets the server do some action. I think this is a validaton check or something.
Is there a way to deactivate that or do I need to use an other provider?
Thanks for your help
From what I've read google and other url shorteners will visit the url to create a preview. I had the same issue when trying to shorten an unsubscribe url and decided to add a confirmation step so that the subscription wouldn't be unsubscribed when shortening the url.
Another solution is to key off the User Agent field and prevent the default action if the User Agent is a url shortening bot.
Since I don't control the User Agent field I was concerned the url shortener service might change the User Agent value in the future and hose everything so I decided not to do it this way.

Check User is Logged in or Nor in Web Browser Control

I m trying to make one test app in windows phone 7.1 And I am using webBrowser control in my app and giving url of external website. User input login details in that form and press submit button. How I Can know the user is logged in.
Thanks,
You can track the URL the user is being redirected to, using the WebBrowser.Navigating event. Check the NavigatingEventArgs.Uri property.
Then you just need to work out the page that the login page redirects to, and if the user is navigating to that then they have successfully logged in.

Resources