Login page first time only


#1

How i can show login page only first time after that show another page when appliction is working i used this :
mainView.router.load({url:’./pages/category.html’, ignoreCache:true, reloadCurrent:true });

is working but bad first show me login page after that redirect make…


#2

Set a cookie that checks if the user has already visited the login page.

Check the cookie on subsequent visits, and send the user to the appropriate page.


#3

my problem no for cookies i save data in localstorage my problem is :
show me login page 2ms after that redirect make

i want like gmail email app as example first time login you do it after that not show again login page app directly show emails


#4

If you’re using a login page, does this mean you’re contacting a backend server? Or can your app run entirely offline?

If you’re contacting a web API then you should just set the route based on the response from the server. Your api calls can either be anonymous or authenticated.


#5

first login page show insert username and password after that connect to server to show if right …
if user right save ing in localstorage for mobile after that go to this page /pages/category.html
next time make app is working not nesseccory make login because data is saved in mobile and i want directly go to this page /pages/category.html without show index.html page …
in index page i put this
document.addEventListener(“deviceready”,userauth, false);
function userauth(){
if(localStorage.getItem(“username”) !== null && localStorage.getItem(“password”) !== null ) {
$$(“view-main”).hide();
mainView.router.load({url:’./pages/category.html’, ignoreCache:true, reloadCurrent:true });

}
}

but problem show me login page 2ms after that redirect make

i want methode to show me /pages/category.html directly after one time login


#6

You should definitely not be storing the user’s password on the device!
The only thing you could store is an authentication token, generated by your server. This is how OAuth2 works. You can find out more here https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2

You could check for the existence of the auth token on the device, and route accordingly.


#7

thank you for help …
i want to ask you for security:
i made app android for show products and sell it i used this:
1)-framework7 + cordova for client…
2)-at server i used normal php and send info by json

i understand from you i should use oauth2 for security…

after that i read from internet most programmer use rest api or fullrest api

if i use oauth2 with my private api is there wrong ???

is there programmer use private api ??


#8

Your existing API will still be usable, you should just research about anonymous requests and authenticated requests. This basically means that after a user is authenticated, each request also posts the token that the user has received. If the API endpoint, doesn’t receive the token, the user is anonymous (not authenticated) and rejects the request.
The term ‘private API’ versus a public one is merely just how you choose to document it. If you are the only one who knows how your API works, and you can create client/server products from it, then it is a private API. But if you take the same API and write documentation for other developers to use it, it is a public one. There is actually no technical difference in the API structure.