Beispiel #1
0
        private SignonDTO IssueAccessToken(InvestorAccount user)
        {
            var accessToken = AccessTokenGenerator.IssueToken(user.Username);

            var keyLoginToken = $"{SystemPlatform.FiiiCoinWork}:Investor:{user.Username}";

            RedisHelper.StringSet(keyLoginToken, accessToken, TimeSpan.FromSeconds(AccessTokenGenerator.EXPIRY_TIME));

            return(new SignonDTO
            {
                AccessToken = accessToken
            });
        }
Beispiel #2
0
        /// <summary>
        /// 生成Web token
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        public static bool SetWebTokenIndRedis(string merchantId, out string accessToken)
        {
            accessToken = null;
            if (string.IsNullOrEmpty(merchantId))
            {
                return(false);
            }

            string key = WebConfig.Redis_Key_Token + merchantId.ToString();

            accessToken = AccessTokenGenerator.IssueToken(merchantId);

            bool result = RedisHelper.StringSet(WebConfig.RedisDB_Web, key, accessToken, new TimeSpan(0, 0, WebConfig.RedisDB_Token_ExpireTime));

            return(result);
        }
Beispiel #3
0
        private LoginOM IssueAccessToken(UserAccount user)
        {
            var keyLoginTokenPrefix = "FiiiPay:Token:";
            var keyLoginToken       = $"{keyLoginTokenPrefix}{user.Id}";
            var accessToken         = AccessTokenGenerator.IssueToken(user.Id.ToString());

            //new FiiiPayRedisCacheManager().SetToken(user.Id, accessToken);
            RedisHelper.StringSet(Constant.REDIS_TOKEN_DBINDEX, keyLoginToken, accessToken, TimeSpan.FromSeconds(AccessTokenGenerator.DefaultExpiryTime));
            var expiresTime = DateTime.UtcNow.AddSeconds(AccessTokenGenerator.DefaultExpiryTime);

            return(new LoginOM
            {
                AccessToken = accessToken,
                ExpiresTime = expiresTime.ToUnixTime().ToString(),
                UserInfo = GetSimpleUserInfoOM(user)
            });
        }
        private SignonDTO GetAccessToken(POS pos, MerchantAccount account)
        {
            MerchantAccessToken token = new MerchantAccessToken
            {
                POSSN    = pos.Sn,
                Identity = account.Username
            };

            string accessToken = AccessTokenGenerator.IssueToken(token);
            string key         = $"{RedisKeys.FiiiPOS_APP_MerchantId}:{account.Username}";

            RedisHelper.StringSet(Constant.REDIS_TOKEN_DBINDEX, key, accessToken);

            return(new SignonDTO
            {
                AccessToken = accessToken,
                SecretKey = account.SecretKey
            });
        }