Inheritance: IPermissionsProvider
Beispiel #1
0
        static Persistance()
        {
            SessionFactory = Fluently.Configure()
                             .Database(() => SQLiteConfiguration.Standard.UsingFile(Settings.DatabaseFile.FullName))
                             .Mappings(mcfg => mcfg.FluentMappings.AddFromAssemblyOf <LocalUser>())
                             .ExposeConfiguration(ExposedConfiguration)
                             .BuildSessionFactory();

            using (var session = SessionFactory.OpenSession())
                using (var trans = session.BeginTransaction())
                {
                    if (!session.Query <LocalChannelInfo>().Any())
                    {
                        ChannelProvider.Setup(session);
                    }

                    if (!session.Query <Permission>().Any())
                    {
                        PermissionProvider.Setup(session);
                    }

                    trans.Commit();
                }
        }
Beispiel #2
0
        private void CreateUser(ISession session, string username, string hashedPassword)
        {
            bool first = !session.Query <LocalUser>().Any();

            var user = new LocalUser {
                HashedPassword = hashedPassword, Username = username
            };

            session.SaveOrUpdate(user);

            if (!first)
            {
                PermissionProvider.CreatePermissions(session, user.UserId,
                                                     PermissionName.SendAudio,
                                                     PermissionName.RequestUserList,
                                                     PermissionName.RequestSource,
                                                     PermissionName.RequestChannelList,
                                                     PermissionName.ChangeChannel);
            }
            else
            {
                PermissionProvider.CreatePermissions(session, user.UserId, (PermissionName[])Enum.GetValues(typeof(PermissionName)));
            }
        }