简体   繁体   中英

Will I regret using Devise for this? RoR, multiple user/admin layers, multi-tenency, fast user switching

My Question

Should I use Devise for this app, use some other auth solution, or roll my own?

What I'm building

I'm building an app that will be used as a kiosk for store employees to log into and record real-time information as they do their work. I need to make it easy for users to swap and authenticate as there may be multiple employees working simultaneously while sharing the kiosk. (Think restaurant Point Of Sale (POS) kiosks - the server walks up, punches in four-digit PIN, and can place orders, etc., very quickly and easily.) I also need several admin layers, and will need to support multi-tenency (I have not decided how I'll do this yet, but I will use multi-tenency), so I'll also have a multi-tiered "admin" layer (for store managers, general managers who might manage multiple stores, and system admins like me).

Summary of the four user layers I anticipate

  1. Store employee - a "user", probably an hourly worker who will use the kiosk (iPad or PC) to record work information. Users will be able to swap out quickly by tapping/clicking their name on a list and entering a four-digit pin (I have no idea how I'll do this yet - that's probably fodder for future SO question).
  2. Store manager * - an "admin" who can view reports for the store and do some other store-specific maintenance.
  3. General manager * - an "admin" who can view reports, do maintenance, and other admin activities for multiple stores.
  4. Super user * - an "admin" who can manipulate the data in the app, see all data, run reports (this is "god mode", basically).

    * All admin roles would log in through an admin login page using standard username/email address-type authentication.

I also plan to set this up so that new General Managers can sign their company up to use the app and add stores for their company. General Managers and Store Managers will be able to add Users (employees) for their stores as well. (So employees won't sign up themselves - General/Store Managers will create and maintain the employees' accounts.)

The signup/authentication story of a new company signing up to use the app

  • General Manager goes to the app website, signs up the company.
  • General Manager provides payment info. (This completes setup of the "Company" account and the "General Manager" account.)
  • General Manager sets up each store (name, location, etc.). This creates "Store" instances, of which the GM is the initial admin.)
  • General Manager creates "Store Manager" accounts for each store. (This completes setup of the initial "Store Manager" accounts.)
  • Store Managers can now log in and set up the data for each store (the things the employees will eventually record information about from the kiosk) and create user accounts for their store's employees. (This completes initial setup of "User" accounts for each store.)
  • Employees can now log in from the kiosk using their PIN.

What I've got right now

Right now I'm set up with the Store Employee and Super User roles - I set it up using this great article: Using Devise for Admin Accounts . So I'm really early in this - it's almost entirely conceptual at this point. If I'm going to backtrack from my initial decision to use Devise, now is the time. I've built most of the basic functionality of the app, and am now doing the web design (look and feel) and working to build the authentication/sign up layer out. Then I'll add the multi-tenency layer.

I'm basically a .Net developer, i just wanted to share my thoughts about multi-tenancy. In my opinion, you should be also spending some time on the muli-tenancy aspects of the application before getting started. Like, consider the case of authenticating the users of the application. Since the users will be belonging to tenants, there are two ways to identify you tenant,

Implicit: by means of using the application's URL.

Explicitly by using a tenant identifier like the store for which he works at.

Also, in the current time, the most preferred authentication mechanism is to have a SSO method that authenticates your application's users. Also, you can make this mode of authentication based on the tenants.. ie configurable. I believe in the success of a SaaS App based on the finer grained level of configurability that it offers for the tenants. I hope that thought not in ROR , this will be of some use to you.

I did end up regretting Devise, and removed it. I replaced it with a "from scratch" solution. This thread is a great guide for removing Devise, and I added an answer describing the resources I used to build my own authentication from scratch:

Ruby: how to uninstall Devise?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM