コード例 #1
0
        /// <summary>
        /// Grants authorization to the given host, such
        /// that subsequent calls to HasGrantedAuthorization with the same host
        /// will return true.
        /// </summary>
        public void GrantAuthorization(string host)
        {
            host = host.ToLowerInvariant();

            var db = Current.WriteDB;

            var newGrant = new UserSiteAuthorization
            {
                CreationDate    = Current.Now,
                SiteHostAddress = host,
                UserId          = this.Id
            };

            db.UserSiteAuthorizations.InsertOnSubmit(newGrant);
            db.SubmitChanges();
        }
コード例 #2
0
ファイル: RestrictionsTests.cs プロジェクト: wy182000/StackID
        public void NoUserSiteAuthorizationInsertWithoutUserId()
        {
            var r = new Restrictions();

            var siteAuth = new UserSiteAuthorization
            {
                UserId = 1
            };

            var updates = new Dictionary <object, Restrictions.ShadowModifiedMember[]>();

            string ignored;

            Assert.IsFalse(r.IsValidChangeSet(updates, new List <object>(), new List <object>()
            {
                siteAuth
            }, new List <object>(), new List <int>(), out ignored));
        }