A business scenario that corresponds to one scenario:
If the implementation does not have access to the view A, view B, view C page and jumps to the login view if the user is not logged in successfully
Add the following in the success branch of the Login.view login Ajax Request:
$.ajax ({
URL: "",
Type: "Get",
DataType: "JSON",
Success:function (res) {
Sessionstorage.setitem ("Isload", True) //If this is a page routing table, you can do the routing control display.
},
Error:function (res) {
Console.log (' res = ', res);
}
})
In the initialization rendering of other pages such as view a, add the following:
var isLoaded = Sessionstorage.getitem ("Isload");
if (!isloaded) {
Window.location = (".. /index.html "); Login Page
}
As a result, each time you log in to the session domain, if you are not logged in successfully (get certified). You do not have permission to access other pages.
Note: Sessionstorage is used because the sessionstorage is emptied after it is closed. Complies with security rules. Sessionstorage is equivalent to a global variable in a single page application (similar to rootscope in angular) that can be shared across all view. It is also possible to implement some mechanism of angular rootscope by Sessionstorage. Here just to do a check whether the login, interested friends can be based on the implementation of routing management.
Sessionstorage Front page Jump Management