Пример #1
0
        internal static TokenInfo ValidaToken(RequestBase request)
        {
            TokenInfo result = null;

            using (var db = new BiblosDS2010APIEntities())
            {
                var token = db.LoginTokens.Where(x => x.IdLoginToken == request.Token).SingleOrDefault();
                if (token != null)
                {
                    if (DateTime.Compare(DateTime.Now, token.DateExpire) > 0)
                    {
                        db.DeleteObject(token);
                    }
                    else
                    {
                        result = new TokenInfo();
                        result.DataScadenza = DateTime.Now.AddMinutes(20);
                        result.Token        = token.IdLoginToken;
                        result.IdCliente    = token.IdCustomer;
                        token.DateExpire    = result.DataScadenza;
                    }
                    db.SaveChanges();
                }
            }
            return(result);
        }
Пример #2
0
 internal static void DeleteDocumentKey(Guid idDocument)
 {
     using (var db = new BiblosDS2010APIEntities())
     {
         var documentKey = db.DocumentKeys.Where(x => x.IdDocument == idDocument).SingleOrDefault();
         db.DeleteObject(documentKey);
         db.SaveChanges();
     }
 }
 /// <summary>
 /// Logout
 /// </summary>
 /// <param name="token">Id del token di autenticazione</param>
 public static void Logout(Guid token)
 {
     try
     {
         logger.DebugFormat("Login Logout:{0}", token);
         using (var db = new BiblosDS2010APIEntities())
         {
             var userLogin = db.LoginTokens.Where(x => x.IdLoginToken == token).FirstOrDefault();
             if (userLogin != null)
             {
                 db.DeleteObject(userLogin);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         //LogOut sempre valida non da mai eccezione
         //throw;
     }
 }