Mutiple Applications

Oct 3, 2011 at 5:17 PM

I would like to use this membership for multiple applications.

A User will login with username, password, and applicationname.  I will need a new Appliationtable to store AppID and AppName.

Would it be it easy to add a new Application model with many to many relationship with the User model?

Oct 5, 2011 at 2:58 AM

you have that ability with this library yes, you can design any model you see fit, as long as it contains the base properties I included in the interface, anything else goes after that. you would just include an ICollection<User> / ICollection<Application> for many-to-many or Application for many-to-one.

I am working on a code rewrite to be released in the next week or so. Trying to add some better configuration options, and cleaner / documented code to the core.

Oct 6, 2011 at 6:03 PM
Edited Oct 6, 2011 at 7:19 PM

I expanded your model as you suggested. Do you see any issues? Also any suggestions on chaning the user creation and validation logic?

	public class BaseUser : IUser<BaseRole,BaseApp>
                  (same as before ....)
public virtual ICollection<BaseApp> Apps { get; set; } public virtual ICollection<BaseRole> Roles { get; set; } } public class BaseRole : IRole<BaseApp,BaseUser> { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid RoleId { get; set; } public string Name { get; set; } public virtual BaseApp App { get; set; } public virtual ICollection<BaseUser> Users { get; set; } } public class BaseApp : IApp<BaseRole,BaseUser> { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid AppId { get; set; } public string AppName { get; set; } public virtual ICollection<BaseRole> Roles { get; set; } public virtual ICollection<BaseUser> Users { get; set; } } #endregion #region Interfaces public interface IUser<TRole,TApp> where TRole : class where TApp : class { (same as before ....) ICollection Roles<TRole> { get; set; } ICollection Apps<TApp> {get; set;} } public interface IRole<TUser,TApp> where TUser : class where TApp : class
		Guid RoleId { get; set; }
		string Name { get; set; }

                 ICollection<TUser> Users { get; set; }
		TApp Apps { get; set; }

         public interface IApp<TUser,TRole> where TUser : class where TRole : class
                 Guid AppId { get; set; }
                 string AppName { get; set; }

                 ICollection<TRole> Roles { get; set; }
                 ICollection<TUser> Users { get; set; }
Oct 6, 2011 at 7:47 PM

My senario is that a user can have mutiple applications and an application can have many users.(many to many) Howeveer, an application can have multiple roles but each role is specific to an application. (one to many).

A role can have mutiple permissions and each permission belong to a specific role.  (I did not list Permission model above for simplicity.)

I may want to add an UserProfile model.  A user can have mutiple profiles and a profile belongs to a single user. (one to many). 

An application can have only one profile per user but a profile can be used for multiple (different) applications. (one to many).



Oct 7, 2011 at 6:47 PM

Well honestly, you do not need to include it in the base roles of the code, the entire system can be designed outside of the source code of the provider using events, and just inheriting. the code only uses interfaces as a base for anyone building a custom model, you must include the interface, and then the interface members, none of the code goes beyond that in using the interface in an IoC container or anything (this would prevent non interface members from being recognized compile / run time).

I'll write up an example as soon as possible that shows how you can extend this without modifying the source code of the provider.