Skip to content

adumrewal/role-based-login-architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Login & Role Based User Authentication Architecture

Tech: Flutter and Firebase

Efficient state management and navigation for apps with specific home screens for various user roles.

Many times when working on an app we come across the following scenario:

  • How does one control navigation and state management in the app wrt login/logout/user-role
  • Every app requires a separate screen for logged in users vs not logged in users
  • Also, if your app has multiple user roles, like Admin, Student, Teacher, Staff, it becomes very cumbersome to manage which view to show for each user and how to ensure one user type does not have access to outside information

Here in this repository I have provided a very simple structure for the app to ensure when there is a change in user state, the app gets updated automatically.

Architecture / Sequence Diagram

sequence-diagram

Screenshots

Login Screen Admin Home Student Home
login-screen admin-portal student-portal

Suppose you are in the login screen and press the login button. In this case the user should be navigated inside the app and we should pop the login screen from the app. Adding if the user is an Admin types, he should be shown screen 2 vs screen 3 or X for other user roles.

Now for a logged in user, when they logout, the entire state of the app should be refreshed and a login screen should be shown. (i.e. They should not have access to previously shown information)

The relevant files are available inside the lib folder. main.dart, routes.dart, loginManager.dart and homePageNavigator.dart are the main files required to create an efficient login structure. Others are just helpers to create a sample app.

Getting Started

A few resources to get you started if this is your first Flutter project:

I use VSCode for running flutter applications. It is very efficient and works like a charm. Open the project folder in VSCode and click on run. Your sample app will get launched.

If you like this repo and would like me to work on more such sample projects, please do let me know or give it a ⭐

If you are working on a flutter project and are stuck anywhere, feel free to reach out. Would be happy to help :)

About

Flutter: Role based user authentication and login management. Simplified and modular architecture

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published