Пример #1
0
        /// <summary>
        /// Static method to Create a user token using the supplied username and password. A valid token will only be provided if the username and password are valid and the account is not disabled nor expired.
        /// </summary>
        /// <param name="userGuid"></param>
        /// <returns></returns>
        internal static UserIdentityToken CreateTokenNoSecCheck(Guid userGuid)         //TODO: do not use session. Token will be stored in Context.User
        {
            UserEntity l_user = new UserEntity();

            l_user.GUID = userGuid;

            // Get the user
            DataAccessAdapter da = new DataAccessAdapter();
            bool didFetch        = da.FetchEntityUsingUniqueConstraint(l_user, l_user.ConstructFilterForUCGUID());

            if (!didFetch || l_user.IsNew)
            {
                return(null);                //We dont have a valid user with that username;
            }
            //UserManager.SetLastLogin(l_user);

            UserIdentityToken l_usertoken = new UserIdentityToken(l_user);

            return(l_usertoken);
        }
Пример #2
0
        public static UserIdentityToken CreateAnonymousToken(Guid anonGuid)
        {
            UserEntity l_user = new UserEntity();

            l_user.GUID = anonGuid;

            // Get the user
            DataAccessAdapter da = new DataAccessAdapter();
            bool didFetch        = da.FetchEntityUsingUniqueConstraint(l_user, l_user.ConstructFilterForUCGUID());

            if (!didFetch || l_user.IsNew)
            {
                return(null);                //We dont have a valid user with that guid;
            }
            UserIdentityToken l_usertoken = new UserIdentityToken(l_user);

            l_usertoken._isAnonymous = true;

            return(l_usertoken);
        }