Пример #1
0
        /// <summary>
        /// Checks wether the login info matches the given credentials
        /// </summary>
        /// <param name="loginModel"></param>
        public static bool Authenticate(Loginmodel loginModel)
        {
            try
            {
                // 01. Check if the user exists
                var _user = Get(loginModel.CredentialName);

                if (_user == null)
                {
                    throw new UserNotFoundException(loginModel.CredentialName);
                }

                var encrypted = SecurityExtensions.Encrypt(loginModel.Password + _user.Salt);

                if (_user.Password == encrypted)
                {
                    DAL_Users.SetAuthenticatedUser(_user.Id);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
 /// <summary>
 /// gets the user by its email
 /// </summary>
 /// <param name="email"></param>
 public static Users GetByEmailAddress(string email)
 {
     try
     {
         return(DAL_Users.GetByEmailAddress(email));
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #3
0
 /// <summary>
 /// returns a list of all users
 /// </summary>
 public static List <Users> GetAll()
 {
     try
     {
         return(DAL_Users.GetAll());
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #4
0
 /// <summary>
 /// returns the authenticated user
 /// </summary>
 public static Users GetCurrentUser()
 {
     try
     {
         return(DAL_Users.GetCurrentUser());
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #5
0
 public static bool Any()
 {
     try
     {
         return(DAL_Users.Any());
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #6
0
 /// <summary>
 /// Logging the current user out
 /// </summary>
 public static void Logout()
 {
     try
     {
         DAL_Users.Logout();
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #7
0
 /// <summary>
 /// gets the user by its username
 /// </summary>
 /// <param name="username"></param>
 public static Users GetByUsername(string username)
 {
     try
     {
         return(DAL_Users.GetByUsername(username));
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #8
0
        /// <summary>
        /// this updates the given user
        /// </summary>
        /// <param name="user"></param>
        /// <param name="pwd"></param>
        public static void Update(Users user, string pwd = null)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(pwd))
                {
                    user = ChangePassword(user, pwd);
                }

                DAL_Users.Update(user);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #9
0
        /// <summary>
        /// creates a new user
        /// </summary>
        /// <param name="user"></param>
        public static void Create(Users user)
        {
            try
            {
                if (user.Id == Guid.Empty)
                {
                    user.Id = Guid.NewGuid();
                }

                DAL_Users.Create(user);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #10
0
 public BL_Users()
 {
     DAL_Users = new DAL_Users();
 }