My scenario is that, when user logs out, jump to the login page. In this case, if user clicks the back button of browser, he would go into the app again. But since session is killed, then he would have some problems to fetch data from server.
so my question is, how to clear browser history or how to disable the back button of browser so user cannot go back into the app again if he is at login page?
I have tried
$scope.$on('$viewContentLoaded', () => {
$location.replace();
})
but it does not work
Related
I have React SPA when I use gtag to track users in Google Analytics. I am confused with data which I see in Real-Time Google Analytics. When app starts or user is routed to new react route I fired event like this to set correct page and log pageView
window.gtag('config', UA-123456789-1, {
groups: 'MYGROUP',
page_path: '/contacts',
})
When user click on button or make some interesting action I fire event like this
window.gtag('event', 'Some button click', {
sendTo: 'MYGROUP',
event_category: 'buttons on main page',
})
Many events is button click on page one and this click move user to another page (on this new page is fired gtag configure). When I watch events in Real-Time Analytics page view, pages is shown like one page delayed. For example gtag events flow and RealTime result
gtag Configure page "/about" -> in GA is showing /about
gtag Event "signIn click" (move user to sign in)
gtag Configure page "/signin" -> in GA is showing /about
gtag Event "contacts click" (move user to contacts)
gtag Configure page "/contacts" -> in GA is showing /signIn
Do you know why this happen or do you have some tips how to fix it? I need log both events and pageView. I am not sure where this delay starts. In some cases I see for example first two pages correctly and third is delayed, sometimes is delayed from first event. Event and configure is fired close together.
Many thanks
Given it’s an SPA, you should manually send the pageview as prescribed here: https://developers.google.com/analytics/devguides/collection/gtagjs/pages#page_view_event.
So there's a login page and let's say a dashboard with certain data fields. When I press logout from the dashboard it redirects me to the login page. But when I hit back button, it brings me back tot he dashboard and technically let's me access data I shouldn't be able to access.
It was solved by refreshing after pressing back button, because it seems that is the page cache loading from memory which needs to be refreshed. But I don't want the user to have to manually refresh.
Any workaround to that, or a completely different solution would be great.
In angular, you can use #hostListner(angular decorator). that is used for handling dom events in angular.
in your project, you can help localStorage and #hostListner
store client information on local storage with javascript.
store local storage
and then in the log-in page
add #hostListner event in component.ts file
event handling
Implement session validation in each of your route $routeChangeStart event. Whenever user loggout clear the session data and redirect it default route which should be your login page.
I'm Using Next.js in my project. I am having payment option in my application., Once I got redirected from the Payment gateway I want to stop user clicking browser back button.
currently, If user click browser back buton it goes back to payment gateway.
I am using next-routesfor routing, redux for state management.,
I tried to stop browser back navigation with this package disable-browser-back-navigation, but the issue remains same.
can anyone help me on this.
I am trying to skip a state after logout in angular ui router SPA. But I am unable to acive this.
dashboard -> login -> view details -> logout -> dashboard
I am logging in dashboard and moving to details state and logging out there. On logout I am moving to dashboard. Now, if I press back button It is again going to view details page. How can I prevent to moving there. Please help me. How can I remove that view details state from history on logout. Of course the history not containing this page bcoz it is SPA. Button I observed them in browser back button long press
I have a question that suppose, I have an Admin Dashboard page, on which I have given a list of users. clicking upon a particular user the details of corresponding user is shown on a different page (say on userDetails.jsp). Now I have a back button on userDetails page, Clicking of which I need to redirect admin to the last visited page that is Admin Dashboard page, I have one solution that I can "Reload" the previos page on clicking back button, but then I feel that there is the overhead of calling a server side API, retrieving all the data, Again redraw the whole admin dashboard page even when there is no change made in the userDetails[because it is read only page, modification is not allowed there]. Is there anyway that I can make user of cache or anything else so that I will not need to go to the server to fetch all the data again. I am using spring MVC, angularjs, Thank you.
On your button's click event add the following code:
$window.history.back();
make sure to use $window rather than window since you're using AngularJS