[Vuejs]-Can I protect certain page in PWA with a pin code?

3👍

You can use a router middleware to prevent the client to navigate elsewhere.

router.beforeEach(function(to, from, next) {
    if (isLocked) {
        alert('Navigation is locked');
        next(false);
    } else {
        next();
    }
});

Here is an example where the waiter can lock the page after selecting the bill. Although it can be automatically set in mounted. You can adjust the code to your own needs.

Jsfiddle

Leave a comment