How to use a 'logged in user' on top of every page,

Posted by wardcouckecac on 18-Apr-2013 06:16

When I have an app that needs to include a "Welcome, <username>" on the top of each page, only when the user is logged in. How can i do this in Tiggzi?

I hope I don't have to include the same code (for example, checking the localStorage for a value and display the label on top of the page accordingly) on every page of the app? Because if I change 1 thing, I have to change it in 20 pages, it's not possible to maintain code like this with such redundancy.

All Replies

Posted by Jens Dahlin on 19-Apr-2013 04:05

I havent worked with OE Mobile or Tiggzi so I can't speak for specific solutions.

Generally for web development though I have found that following the Front Controller Pattern (http://en.wikipedia.org/wiki/Front_Controller_pattern) often can be a good idea.

What you do is that you have one (front controller) program that handles all requests and then call underlying programs that handle different actions. Thus you have one centralized point of inserting things like authentication. You can also move common objects on a web site (like for instance a footer and a header) to this program.

You have to plan a good architecture before starting - otherwise the front controller will become a real mess (I know that for a fact).

This thread is closed