Example #1
0
        public static bool Autentication(string email, string passaword)
        {
            try
            {
                passaword = BLEncrypt.Encrypt(passaword);

                var user = CRUD <T>
                           .Find(u => u.Email == email && u.Password == passaword && u.Active == true);

                if (user == null)
                {
                    return(false);
                }

                user.Token = Guid.NewGuid().ToString();
                CRUD <T> .Update(user);

                Current.Response.Cookies.Add(
                    new HttpCookie(_cookie, user.Token)
                {
                    Expires = DateTime.Now.AddYears(1)
                });

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #2
0
        public static bool Create(T user)
        {
            try
            {
                user.Password = BLEncrypt.Encrypt(user.Password);

                CRUD <T> .Add(user);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }