コード例 #1
0
        /// <summary>
        /// Creates the authenticated user application authentication token.
        /// This Can Only Be Returned After A Successful Login
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="loginTime">The login time.</param>
        public AppAuthToken CreateAuthenticatedUserToken(AppAuthToken emptyToken, string userId, DateTime loginTime)
        {
            // At This Point We Assume the UserId is Valid
            AppAuthToken token = new AppAuthToken();

            token.User       = _userDataService.Get(userId);
            token.Role       = _roleDataService.Get(this.User.RoleId);
            token.LoginTime  = loginTime;
            token.LogoutTime = DateTime.MinValue;
            token.Id         = emptyToken.Id;     //Id From Old Token
            token.TokenType  = AppAuthTokenType.Authenticated;

            Clear(userId);             // Clears any existing AppAuth Tokens For This User

            UpdateAppAuthToken(token); // Update The Database Record

            return(token);
        }