Beispiel #1
0
        /// <summary>
        /// User Authentication.
        /// This method uses the data access component to verify that the
        /// current user exists in the database and authenticate it in case
        /// the user exists by comparing passwords. If authenticated,
        /// the current user gets all the fields from the obtained user.
        /// </summary>
        /// <returns>True if the has been properly authenticated and false 
        ///     otherwise (no matter what reason).</returns>
        public bool verifyUser()
        {
            bool verified = false;

            UserDAC userDAC = new UserDAC();
            // Obtain the full user with the same nickname from the database.
            UserBE authUser = userDAC.getByNick(nickname);

            string auxiliar = authUser.Password;

            // Compare the nicknames, taking into account that if the user
            // is not present in the database the fields will be empty
            // and then the nicknames will not match. Compare the
            // passwords to authenticate.
            if (authUser.nickname == nickname && ValidatePassword(password, authUser.password))
            {
                this.Name = authUser.Name;
                this.LastName = authUser.LastName;
                this.Email = authUser.Email;
                this.Credit = authUser.Credit;
                this.ProfilePicture = authUser.ProfilePicture;

                verified = true;
            }

            return verified;
        }
Beispiel #2
0
 /// <summary>
 /// User Retrieval.
 /// Retrieves an user from the database using the current user nickname.
 /// </summary>
 /// <returns>The full user recovered from the DB.</returns>
 public UserBE getUserByNick()
 {
     UserDAC userDAC = new UserDAC();
     return userDAC.getByNick(nickname);
 }