I am building a RoR application, and I am trying to develop an invitation mechanism, in which users can invite other users by email.
However, I want that if a user already exists in my users table it will reference to it, or, when a non-existing user was invited and he gets registered, I have a reference to it too.
What is the best modelling schema for such scenario?
Thanks!
Maybe just use
devise_invitable?
Related
I have an ASP.NET MVC application that is used by different customers. Currently the app is set up to use individual user accounts. I have built some authorization logic around that and would like to keep the logic unchanged.
I got a request that some of the customers would like to perform authentication for their users with their Azure Active Directory. I have uncommented the app.UseMicrosoftAccountAuthentication part from Startup.Auth.cs. I registered the app as multi-tenant in my AAD. I managed to get the whole thing running and users now have the possibility to link their accounts with AAD and use it for authentication.
However, I encountered a few problems I am struggling with:
In order for the user to link his account with AAD he needs to set up an individual login/pass account in the first place. How can I avoid that? I want to have the users either authenticating with login/pass or with AAD, not both at the same time.
I have no control over which account the user uses to authenticate. Let's assume I expect the user to use an account in domainx.com, but if they link domainy.com account it will still work. I need to have some kind of way to compare the expected domain with the actual one that comes back from AAD. How can I do that?
One of the ideas to tackle the problem was to have a customer admin create the user accounts for them. The issue is that in AspNetUserLogins I need to store the user's AAD ID, not the email. How can I query AAD to check the UserID based on the email?
I couldn't find information on this. I have an iOS app, written in swift. Firebase is my storage and database place. For now, I authenticate my users with email and password (no social media auth). My question is - is it possible after they've created their account to create many sub accounts? And if so, how do I track those (meaning, which is the primary account and how to switch between them - something like twitter and the way it allows to use multiple accounts and switch between them)?
My goal is to allow each user to have/create multiple accounts, make 1 account primary and the rest would be secondary accounts. Not sure if Firebase allows any of this though. I know this is broad description, but I want to make sure that this is indeed possible before I try to do anything like that. Any ideas?
We are creating a marketplace, we are using stripe for payments and we are creating stripe managed accounts for our users when they register. We are trying to prevent anything that could go wrong and I am thinking scenarios that could mess up things and how we need to handle them.
I was wondering how would you handle a user who selected wrong country when he registered and the stripe managed account on your platform was created with the wrong country? According to stripe documentation you can't change the country of a managed account later. Do you just drop and re-create the stripe managed account? What if the managed account has received funds from a charge and the user find out the problem later?
I would say the best and the only way to handle this is to drop and re-create like you said.
If he was able to receive funds, this is not a problem. You can refund anyway if you need to. Just keep every charge / bank transfer in your database.
I don't see why it could be a problem, you can re-associate the bank account easily for example.
We're developing a Rails app that will serve as a backend for multiple apps. The Rails app will have a web CMS that will let admin users to manage their mobile apps (one admin user can have 1..N mobile apps).
The same Rails app will also serve as an API for those mobile apps. The mobile apps are completely separated one from each others, not sharing any data among them. We have users with different roles (global_admin which manages his app in the CMS, place_manager which manages his place in the app within the CMS, and users of the mobile app). These users are not shared between apps (if a user signs up in a mobile app, he will be able to log in only in that app; so if he wants to log in another mobile app he needs to register again).
Which is the best approach to achieve this? We are thinking about:
Option 1: we can have a single User model, with different roles on different apps (global_admin on app 1, user on app 2, manager on app 3...). If a user signs up for app 1, a record is created, and if he signs up for app 2, we only add a role to it, but he thinks that he created a new account.
Option 2: we can create a record for each user on each app (removing the uniqueness constraint on the email field)
Option X: ideas?
Thank you in advance
The API/API users scenario looks like a situation for multi-tenancy in which each app runs as a separate instance. You can look at something like Apartment for database level multitenancy, or Milia for app level multitenancy.
Database level is generally easier to manage, but you will need a workaround for the global admin requirement.
I suggest the following approach if you would like to use a single rails application for multiple mobile apps.
For users you can have different API returning different kinds of users, specific to the application requirement.
Use STI to differentiate users for each apps(in this way, you could have only a single table for users but different models)
These users are not shared between apps (if a user signs up in a
mobile app, he will be able to log in only in that app; so if he wants
to log in another mobile app he needs to register again).
In my opinion these are three different Rails apps. Obviously the apps have nothing in common, in particular no data is shared.
I think Option 1 would work well in your case. You can setup a has_many :through relationship between apps and users that will contain information regarding the user's role for that particular application (assuming only one role per user per application).
With this approach the workflow would be a bit different than what you describe though. If the user is not registered at all (i.e. no record with that email exists), they will need to signup (email + password) at which point you'll create the user record (with hashed password) and setup the association to the mobile application. If the user IS already registered, you don't want them entering a new password again, you'll simply want to setup the association. This can be handled via first_or_create. Hope this helps.
I'm developing an application in Rails 3. In the application, users are allowed to send e-mails using their existing email account settings. What's the best approach to define per user settings for every user's credentials?
Regards,
Liviu
Given you'd probably want to offer the option for users to change/update their settings, they should go in a model. After that, it comes down to taste...
If you have only a few settings, you could store them directly in the User model. If you have lots of settings, you could have a separate UserProfile model that belongs_to User.