Ejemplo n.º 1
0
        public bool HasAccess(Enumerators.LoginType LoginType, ref string ErrorMessage)
        {
            if (!Active)
            {
                ErrorMessage = "Your user is inactive";
                return(Active);
            }

            if (UserBlock)
            {
                ErrorMessage = "Your user is blocked, please check your email box";
            }

            bool isClient        = Role.AccessLevel == Enumerators.AccessLevel.Client;
            bool isAdministrator = !(Role.AccessLevel == Enumerators.AccessLevel.Client);

            switch (LoginType)
            {
            case Enumerators.LoginType.Site:
                ErrorMessage = !isClient ? "Unathorized login" : string.Empty;
                return(isClient);

            case Enumerators.LoginType.API:
                ErrorMessage = !isClient ? "Unathorized login" : string.Empty;
                return(isClient);

            case Enumerators.LoginType.Administrator:
                ErrorMessage = !isAdministrator ? "Unathorized login" : string.Empty;
                return(isAdministrator);

            default:
                ErrorMessage = "Unathorized login";
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool LoginIsValid(string userName, string password, Enumerators.LoginType LoginType, ref string ErrorMessage)
        {
            User user = _baseRepository.GetFirstOrDefault(x => x.UserName.Equals(userName), true);

            if (user == null)
            {
                ErrorMessage = "User not found";
                return(false);
            }

            if (!user.HasAccess(LoginType, ref ErrorMessage))
            {
                return(false);
            }

            password = CriptoUtilitary.sha256encrypt(password);

            bool isValid = user.Password.Equals(password);

            ErrorMessage = isValid ? string.Empty : "Username or passaword are incorrect";

            return(isValid);
        }
Ejemplo n.º 3
0
        public User GetUserComplete(long Id, Enumerators.LoginType loginType)
        {
            var query = QueryUserComplete();

            return(query.FirstOrDefault(user => user.Id == Id));
        }
Ejemplo n.º 4
0
 public bool LoginIsValid(string userName, string password, Enumerators.LoginType LoginType, ref string ErrorMessage)
 {
     return(_userService.LoginIsValid(userName, password, LoginType, ref ErrorMessage));
 }