Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tokenId"></param>
        /// <param name="ignoreExpiry"></param>
        /// <returns></returns>
        private int TokenIndex(Guid tokenId, bool ignoreExpiry)
        {
            TokenEntity tokenEntity = Token.Instance.lstUserToken.Find(x => x.TokenId == tokenId);

            if (tokenEntity == null)
            {
                return(-1);
            }

            if ((!ignoreExpiry) && (tokenEntity.ExpiresOn < DateTime.Now))
            {
                return(-1);
            }

            return(Token.Instance.lstUserToken.IndexOf(tokenEntity));
        }
Esempio n. 2
0
 /// <summary>
 ///  List of user Toke Info
 /// </summary>
 /// <param name="userid"></param>
 /// <returns></returns>
 public TokenEntity Generate(string userid)
 {
     lock (LockObj)
     {
         Guid        token       = Guid.NewGuid();
         TokenEntity tokenEntity = new TokenEntity()
         {
             TokenId   = token,
             IssuedOn  = DateTime.Now,
             ExpiresOn = DateTime.Now.AddSeconds(Convert.ToDouble(ConfigurationManager.AppSettings["TokenDuration"])),
             UserId    = userid
         };
         lstUserToken.Add(tokenEntity);
         return(tokenEntity);
     }
 }