Help with login authentication and offline webapp

46 views
Skip to first unread message

Bart Cockheyt

unread,
Mar 21, 2014, 1:33:02 PM3/21/14
to iphone...@googlegroups.com
Hy,
 
I'm making an 1 file webapp (different screens in 1 html file) with user authentication.
I tried different type of scripts but all seem to lack to work flawless with the iUI screen setup.
If i use a script with separate login files it screws up the backlink in the topbar (displaying the login link in the first screen).
Another thing is that it uses a mysql database to store the userdata, thats ok, but one of the goals of the webapp is to also make it usable when offline (cache).
Has anyone any ideas on how to implement something like this (if possible with working example)?
 
What i need to do is this:
 
- Making the login screen part of the index screen (load screen "login" if not logged in, else display other content, or a script that can handle the #_screenid tag)
- Using a cacheble database (secure so no flat file, maybe msqli?) so it also works when site is cached/offline
- Letting users change there password
- If possible admin the users when logged in as admin, add users, delete users, change user password.
- NO user registration
 
Curently i'm using this script: http://php-login-script.com/
It works but i have the backlink isue and the "stay logged in" doesen't work (and is not going to work for offline usage), but it gives an idea of what i'm trying to do here.
 
Any help, pointers, tutorials, scripts are welcome.
 
 
 

John Biddulph

unread,
Mar 21, 2014, 1:39:07 PM3/21/14
to iphone...@googlegroups.com
You've probably seen my new app 2014-football?!
I use PhoneGap and get my data from an external site using JSON

Hope this helps

J



Sent from my iPad
--
You received this message because you are subscribed to the Google Groups "iPhoneWebDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iphonewebdev...@googlegroups.com.
To post to this group, send email to iphone...@googlegroups.com.
Visit this group at http://groups.google.com/group/iphonewebdev.
For more options, visit https://groups.google.com/d/optout.

Bart Cockheyt

unread,
Mar 21, 2014, 2:12:28 PM3/21/14
to iphone...@googlegroups.com
Hy,
 
It's not a native app but a 100% web-app.
Its going to be used by a select group of users but one goal is that thay can still use the app if there is no internet available.
 

Op vrijdag 21 maart 2014 18:39:07 UTC+1 schreef john.mb...@googlemail.com:

Remi Grumeau

unread,
Mar 21, 2014, 2:20:50 PM3/21/14
to iphone...@googlegroups.com
Hi Bart,

Is content dynamic or static?

If static and not sensible, you do the login/pass test only online on first access and use manifest to cache all files locally.
If dynamic, then well … it's a complicated job :)


Remi

Mogens Beltoft

unread,
Mar 21, 2014, 2:20:48 PM3/21/14
to iphone...@googlegroups.com
Hi,

Do you need all that user management?
How about a single fixed excrypted password in javascript?

/Mogens

Bart Cockheyt

unread,
Mar 21, 2014, 3:54:26 PM3/21/14
to iphone...@googlegroups.com
The content itself is static.
There are a few dynamic bits but the user is warned that those do not work when offline.
 
Its content is sensible, i'm ok if it only checks login when online, but i'm not doing it just once...
 

Op vrijdag 21 maart 2014 19:20:50 UTC+1 schreef Remi Grumeau:

Bart Cockheyt

unread,
Mar 21, 2014, 4:04:36 PM3/21/14
to iphone...@googlegroups.com
Hi,
 
I don'r realy need all, it would be usefull but not needed.
What i do need is letting the user change its password.
That's the only right the user is granted.
Every thing eles, from creating acount to managing is is done by admin, directly in database or using something like a admin gui.
 
one login is not an option.
it is used by my company and if someone leaves the company we can block/delete his useracount.
 
The user is suposed the be online 100% of the time, but sometimes there is no network but i would like to still offer most of the content in those sitiuations.
 

Op vrijdag 21 maart 2014 19:20:48 UTC+1 schreef Mogens Beltoft:

Bart Cockheyt

unread,
Mar 21, 2014, 4:42:51 PM3/21/14
to iphone...@googlegroups.com
Content is static.
 
Its also sensible, so i need a userbased login.
Only first time login is no option.
only login online but not offline(using some sort of offline check) is an option.
 

Op vrijdag 21 maart 2014 19:20:50 UTC+1 schreef Remi Grumeau:
Hi Bart,

Bart Cockheyt

unread,
Mar 21, 2014, 4:44:31 PM3/21/14
to iphone...@googlegroups.com
Hi,
 
Not completely.
I do need to give the user the ability to change its password.
Everything else can be done directly in database bij admin or using an admin gui.
 

Op vrijdag 21 maart 2014 19:20:48 UTC+1 schreef Mogens Beltoft:
Hi,

Remi Grumeau

unread,
Mar 21, 2014, 6:36:29 PM3/21/14
to iphonewebdev
There is only one way to get a webapp offline today: cache manifest.

Cache manifest is pretty simple on the paper: once online, you access to an url. This url as a "manifest" attribute in the html tag, so the browser knows where to find it and read it.
This file is a list of urls you want the browser to keep a copy locally. Those urls are grouped as "cache", "fallback" & "network". urls could refer to any file (except videos afaik). But once the browser have cached those urls locally, he will simply not ask the server again to serve this file. except the manifest file itself got corrupt, updated or is missing. Even is user phone/tablet has signal. That's the whole point.

This is why i'm asking if the content is sensible and if you need offline login.

If not, then do the login online, and only put a manifest reference on the html tag once user is logged in. So you know only logged users can has a manifest-based local copy of the app. 
This could be "simple" to implement, but means you store the app & its content in its logged status & until user keeps offline, he can access app+content forever. (if user is banned or fired, just empty his/her manifest file and app would be removed locally - then next time it would ask online to the server to serve the content -> login screen).

If you need user to login each time + have dynamic content, then you need to totally recreate the app to split everything between what's the app & what's the content. So you can use the manifest file to store what is the app files, and populate the app with datas from the online database via Ajax calls (when online) or from the local storage (localStorage or localDatabase are the two options). The exact same process of a native app in fact, and the only way to do it properly. Here, you can ask online for login/pass check, and fallback to an localStorage hash test when no signal / too long.

Not an easy job for sure, but a very interesting one, and totally server-side tech agnostic (in both cases).


I'll give you 2 examples using Emy rather than iUI just because demos are online and functional, but the exact same could be done with iUI since it's not really related to the frontend library at all.

(see you the logo image switch from "online" to "offline", based on what's in fallback in its manifest file)

(see how views are empty, datas stored in localStorage as a JSON string, parsed onload to populate the app)

Hope this help.

Remi

Reply all
Reply to author
Forward
0 new messages