Beispiel #1
0
        /// <summary>
        /// Logon a user by the username and password
        /// </summary>
        /// <param name="userName">The username</param>
        /// <param name="password">The unencrypted password</param>
        /// <returns>The user if one is found to match</returns>
        public AMFUserLogin LogonUser(string userName, string password, string loginSource)
        {
            AMFUserLogin retVal = null;

            AMFUserLogin targetUser = this.UserRepository.GetByEmail(userName);

            if (targetUser != null && targetUser.UserStatus == UserStatus.Active)
            {
                byte[] passwordSalt = Convert.FromBase64String(targetUser.PasswordSalt);

                if (SHA1HashUtility.ValidatePassword(password, targetUser.PasswordHash, passwordSalt, AMFUserLogin.SaltIterations) == true)
                {
                    retVal = targetUser;
                }
            }

            if (retVal == null)
            {
                this.AddLoginAttempt(false, loginSource, userName, targetUser);
            }
            else
            {
                this.AddLoginAttempt(true, loginSource, userName, targetUser);
            }

            return(retVal);
        }
Beispiel #2
0
        public ActionResult ConfirmPromise(long paymentId, long playerSeasonId)
        {
            if (this.CurrentPrincipal == null || this.CurrentPrincipal.IsAuthenticated == false)
            {
                return(this.RedirectToAction("Signin", "User"));
            }
            else
            {
                Payment targetPayment = this.ServiceManager.PaymentService.ConfirmPromise(this.CurrentPrincipal.User.Id, playerSeasonId, paymentId);

                if (targetPayment != null)
                {
                    //ADD CODE HERE FOR SENDING EMAIL TO PLAYER AND KERRI ABOUT PAYMENT
                    EmailService       sendPlayerEmail  = new EmailService();
                    EmailConfiguration emailConfig      = new EmailConfiguration();
                    AMFUserLogin       playerDemoInfo   = this.ServiceManager.UserService.GetByEmail(this.CurrentPrincipal.User.Email);
                    PlayerSeason       playerSeasonInfo = this.ServiceManager.SeasonService.GetPlayerSeasonById(playerSeasonId);

                    sendPlayerEmail.SendThankYouForPaymentEmail(this.CurrentPrincipal.User.Email, emailConfig, playerDemoInfo, playerSeasonInfo);

                    return(this.RedirectToAction("Season"));
                }
                else
                {
                    ConfirmPaymentModel retVal = new ConfirmPaymentModel();

                    PlayerSeason playerSeason = this.ServiceManager.SeasonService.GetPlayerSeasonById(playerSeasonId);
                    retVal.PaymentDetails = playerSeason.Payments.FirstOrDefault(p => p.Id == paymentId);
                    retVal.PlayerInfo     = this.CurrentPrincipal.User;
                    return(this.View("Confirm", retVal));
                }
            }
        }
Beispiel #3
0
        public AMFUserLogin Register(String firstName, String lastName, String userName, string password, string passwordHint, String USAHockeyNum, String DOB, String Address1, String Address2, String City, String State, String ZipCode, String Phone1, String Phone2, String Emergency1, String Emergency2, String YearsExp, PlayerLevel playerLevel, String Internet, String Referral, String Tournament, String Other)
        {
            AMFUserLogin retVal = null;

            AMFUserLogin userLogin = UserFactory.Create(userName, password, firstName, lastName, passwordHint);

            userLogin.USAHockeyNum = USAHockeyNum;
            userLogin.DOB          = DOB;
            userLogin.Address1     = Address1;
            userLogin.Address2     = Address2;
            userLogin.City         = City;
            userLogin.State        = State;
            userLogin.ZipCode      = ZipCode;
            userLogin.Phone1       = Phone1;
            userLogin.Phone2       = Phone2;
            userLogin.Emergency1   = Emergency1;
            userLogin.Emergency2   = Emergency2;
            userLogin.YearsExp     = YearsExp;
            userLogin.Level        = playerLevel;
            userLogin.Internet     = Internet;
            userLogin.Referral     = Referral;
            userLogin.Tournament   = Tournament;
            userLogin.Other        = Other;
            retVal = this.UserRepository.Save(userLogin);

            return(retVal);
        }
Beispiel #4
0
        public void UserRepositoryTestSave()
        {
            string       testEmail  = this.GenerateEmail(Guid.NewGuid().ToString("N"));
            AMFUserLogin testUser   = this.RepositoryManager.UserRepository.GetByEmail(testEmail);
            AMFUserLogin foundItem  = null;
            string       uniqueTest = Guid.NewGuid().ToString("N").Substring(0, 30);

            if (testUser == null)
            {
                testUser          = this.CreateTestUser(testEmail);
                testUser.Email    = testEmail;
                testUser.LastName = uniqueTest;
                foundItem         = this.RepositoryManager.UserRepository.Save(testUser);
            }
            else
            {
                testUser.LastName = uniqueTest;
            }

            foundItem = this.RepositoryManager.UserRepository.GetByEmail(testUser.Email);

            Assert.IsNotNull(foundItem);
            Assert.IsTrue(foundItem.Email == testUser.Email);
            Assert.IsTrue(foundItem.LastName == uniqueTest);
        }
Beispiel #5
0
        private string GenerateEmailDetails(AMFUserLogin playerInfo, PlayerSeason playerSeasonInfo)
        {
            string retVal = "\n" + "\n" + "First Name: " + playerInfo.FirstName + "\n" + "Last Name: " + playerInfo.LastName + "\n" + "Email Address: " + playerInfo.Email + "\n" +
                            "USA Hockey Number: " + playerInfo.USAHockeyNum + "\n" + "DOB: " + playerInfo.DOB + "\n" + "Address: " + playerInfo.Address1 + " " + playerInfo.Address2 + "\n" +
                            "City: " + playerInfo.City + "\n" + "State: " + playerInfo.State + "\n" + "Zip Code: " + playerInfo.ZipCode + "\n" + "Primary Phone: " + playerInfo.Phone1 + "\n" +
                            "Secondary Phone: " + playerInfo.Phone2 + "\n" + "Emergency Contacts: " + playerInfo.Emergency1 + ", " + playerInfo.Emergency2 + "\n" + "Years Experience: " + playerInfo.YearsExp + "\n" +
                            "Experience Level: " + playerInfo.Level + "\n" + "\n" + "Programs requested: " + "\n";

            for (int i = 0; i < playerSeasonInfo.Programs.Count; i++)
            {
                retVal = retVal + playerSeasonInfo.Programs[i].Name + "  ";
            }

            retVal = retVal + "/n" + "/n" + "Payment Details listed below: " + "/n";
            for (int x = 0; x < playerSeasonInfo.Payments.Count; x++)
            {
                retVal = retVal + "Payment Method: " + playerSeasonInfo.Payments[x].PaymentMethod + ", ";
                if (playerSeasonInfo.Payments[x].PaymentMethod.Equals("Check"))
                {
                    retVal = retVal + "Check Number: " + playerSeasonInfo.Payments[x].AdditionalDetails + ", ";
                }
                retVal = retVal + "Payment Amount: " + playerSeasonInfo.Payments[x].Amount + ", ";
                retVal = retVal + "Payment Promised On: " + playerSeasonInfo.Payments[x].DateSubmitted + " ";
            }
            return(retVal);
        }
Beispiel #6
0
        public ActionResult ProcessSignin(string userName, string password, string oauthToken)
        {
            if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
            {
                // yes actually look up the user, but for now
                AMFUserLogin user = this.ServiceManager.UserService.LogonUser(userName, password, this.Request.UserHostAddress);

                if (user != null)
                {
                    this.SetCurrentUser(user);

                    if (!string.IsNullOrEmpty(oauthToken))
                    {
                        return(this.GrantAccess(oauthToken));
                    }
                    else
                    {
                        if (this.CurrentPrincipal.IsInRole(OAuthRoles.Administrator.ToString()))
                        {
                            return(this.Redirect("/Admin/Management/Index"));
                        }
                        else
                        {
                            return(this.View(user));
                        }
                    }
                }
            }

            return(this.Signin(oauthToken));
        }
Beispiel #7
0
        private string GenerateEmailDetails(AMFUserLogin playerInfo)
        {
            string retVal = "\n" + "\n" + "First Name: " + playerInfo.FirstName + "\n" + "Last Name: " + playerInfo.LastName + "\n" + "Email Address: " + playerInfo.Email + "\n" +
                            "USA Hockey Number: " + playerInfo.USAHockeyNum + "\n" + "DOB: " + playerInfo.DOB + "\n" + "Address: " + playerInfo.Address1 + " " + playerInfo.Address2 + "\n" +
                            "City: " + playerInfo.City + "\n" + "State: " + playerInfo.State + "\n" + "Zip Code: " + playerInfo.ZipCode + "\n" + "Primary Phone: " + playerInfo.Phone1 + "\n" +
                            "Secondary Phone: " + playerInfo.Phone2 + "\n" + "Emergency Contacts: " + playerInfo.Emergency1 + ", " + playerInfo.Emergency2 + "\n" + "Years Experience: " + playerInfo.YearsExp + "\n" +
                            "Experience Level: " + playerInfo.Level + "\n" + "\n";

            return(retVal);
        }
Beispiel #8
0
        /// <summary>
        /// Register a user with the system
        /// </summary>
        /// <param name="userName">The username of the user</param>
        /// <param name="password">The users password</param>
        /// <param name="passwordHint">The password hint for forgotten passwords</param>
        /// <param name="firstName">The users password</param>
        /// <param name="lastName">The users last name</param>
        /// <returns>An instance of a user</returns>
        public AMFUserLogin Register(string userName, string password, string passwordHint, string firstName, string lastName)
        {
            AMFUserLogin retVal = null;

            AMFUserLogin userLogin = UserFactory.Create(userName, password, firstName, lastName, passwordHint);

            retVal = this.UserRepository.Save(userLogin);

            return(retVal);
        }
Beispiel #9
0
        private AMFUserLogin CreateTestUser(string emailAddress)
        {
            AMFUserLogin retVal = new AMFUserLogin();

            retVal.Email     = emailAddress;
            retVal.FirstName = "Artie";
            retVal.LastName  = "Test";
            retVal.UpdatePassword(TestHashedPassword, TestPasswordSalt);

            return(retVal);
        }
Beispiel #10
0
        /// <summary>
        /// Register a new user with the site
        /// </summary>
        /// <param name="registerModel">The incoming parameters used to register the user</param>
        /// <returns>The Registered user view</returns>
        public ActionResult Register(AMFUserLogin userLogin)
        {
            AMFUserLogin retVal = userLogin;

            if (retVal == null)
            {
                retVal = new AMFUserLogin();
            }

            return(this.View(retVal));
        }
Beispiel #11
0
        public static AMFUserLogin GenerateNewUser(int userId, string userName, string hashedPassword, string passwordSalt, int passwordIterations)
        {
            AMFUserLogin retVal = new AMFUserLogin();

            retVal.Id        = userId;
            retVal.Email     = userName;
            retVal.FirstName = string.Empty;
            retVal.LastName  = string.Empty;
            retVal.UpdatePassword(hashedPassword, passwordSalt);

            return(retVal);
        }
Beispiel #12
0
        public ActionResult Save(AMFUserLogin user)
        {
            if (user != null)
            {
                using (this.ServiceManager.UnitOfWork.BeginTransaction())
                {
                    this.ServiceManager.UserService.Update(user.Id, user.FirstName, user.LastName, user.UserStatus, user.Role);
                    this.ServiceManager.UnitOfWork.EndTransaction(true);
                }
            }

            return(this.RedirectToAction("Index"));
        }
Beispiel #13
0
        public static AMFUserLogin Create(string userName, string password, string firstName, string lastName, string passwordHint)
        {
            AMFUserLogin retVal = new AMFUserLogin();

            retVal.Email        = userName;
            retVal.FirstName    = firstName;
            retVal.LastName     = lastName;
            retVal.PasswordHint = passwordHint;
            retVal.UpdatePassword(password);
            retVal.DateCreated = DateTime.Now;

            return(retVal);
        }
Beispiel #14
0
        public bool Delete(long id)
        {
            bool retVal = false;

            AMFUserLogin targetUser = this.UserRepository.GetById(id);

            if (targetUser != null)
            {
                retVal = this.UserRepository.Delete(targetUser);
            }

            return(retVal);
        }
Beispiel #15
0
        /// <summary>
        /// this action returns the partial view to show the password hint
        /// </summary>
        /// <param name="emailAddress">The email address of the user</param>
        /// <returns>An MVC view</returns>
        public ActionResult PasswordHint(string emailAddress)
        {
            PasswordHintModel retVal = new PasswordHintModel();

            AMFUserLogin targetUser = this.ServiceManager.UserService.GetByEmail(emailAddress);

            if (targetUser != null)
            {
                retVal.PasswordHint = targetUser.PasswordHint;
            }

            return(this.View(retVal));
        }
Beispiel #16
0
        /// <summary>
        /// Update the editable fields for a User
        /// </summary>
        /// <param name="userLogin">The source user</param>
        /// <returns>The updated user</returns>
        public AMFUserLogin Update(long userId, string firstName, string lastName, string password)
        {
            AMFUserLogin retVal = this.UserRepository.GetById(userId);

            if (retVal != null)
            {
                retVal.FirstName = firstName;
                retVal.LastName  = lastName;
                retVal.UpdatePassword(password);

                retVal = this.UserRepository.Save(retVal);
            }

            return(retVal);
        }
Beispiel #17
0
        public void UserRepositoryTestGetByEmail()
        {
            string testEmail = this.GenerateEmail(Guid.NewGuid().ToString("N"));

            AMFUserLogin foundItem = this.RepositoryManager.UserRepository.GetByEmail(testEmail);

            if (foundItem == null)
            {
                this.RepositoryManager.UserRepository.Save(this.CreateTestUser(testEmail));
            }

            foundItem = this.RepositoryManager.UserRepository.GetByEmail(testEmail);
            Assert.IsNotNull(foundItem);
            Assert.IsTrue(foundItem.Email == testEmail);
        }
Beispiel #18
0
        /// <summary>
        /// Update the editable fields for a User
        /// </summary>
        /// <param name="userLogin">The source user</param>
        /// <returns>The updated user</returns>
        public AMFUserLogin Update(long userId, string firstName, string lastName, UserStatus userStatus, RoleType.Id userRole)
        {
            AMFUserLogin retVal = this.UserRepository.GetById(userId);

            if (retVal != null)
            {
                retVal.FirstName  = firstName;
                retVal.LastName   = lastName;
                retVal.UserStatus = userStatus;
                retVal.Role       = userRole;

                retVal = this.UserRepository.Save(retVal);
            }

            return(retVal);
        }
Beispiel #19
0
//        public ActionResult IgnoreThisForNow(AMFUserLogin newPlayer, String formAction, String paymentPortion, String paymentAmount, String paymentType, String checkNumber)
//        {
//            /**
//             * pass parameters into page,

//             * Eventually, query database to get program pricing  -- Hard coded just to get it up and running

//             * * render page with registrations
//             * * Show program pricing and totals
//             * * Give choice of 50% payment, full payment, or other amount
//             * * Give choice of payment options: check or PayPal
//             *
//             * Update player registration
//             * Send email with registration confirmation

//             * include PayPal payment button and check number fields
//             *
//             * *Save payment info into database
//             * *Send email with payment option, PayPay or Check number, and payment amount entered
//             * */

//            //Decimal PaymentAmount = paymentAmount;
//            //String CheckNumber = checkNumber;

//            DateTime date = DateTime.Now;

//            int x;
//            if (formAction == "complete")
//            {
//                //Do I need to use a different order of operations
//                x = 1;
//            }
//            else
//            {
//                //Form action == null
//                x = 0;
//            }


//            AMFUserLogin confirmedPlayer = this.ServiceManager.UserService.Update(newPlayer.FirstName, newPlayer.LastName, newPlayer.Email, newPlayer.USAHockeyNum, newPlayer.DOB, newPlayer.Address1, newPlayer.Address2, newPlayer.City, newPlayer.State, newPlayer.ZipCode, newPlayer.Phone1, newPlayer.Phone2, newPlayer.Emergency1, newPlayer.Emergency2, newPlayer.YearsExp, newPlayer.Level, newPlayer.Internet, newPlayer.Referral, newPlayer.Tournament, newPlayer.Other, newPlayer.LTP, newPlayer.Tuesday, newPlayer.Wednesday, newPlayer.Stickhandling, newPlayer.Somerville, newPlayer.Games, newPlayer.DateCreated, newPlayer.UserStatus, newPlayer.PasswordHint);

//            ViewBag.FirstName = newPlayer.FirstName;

//            ViewBag.LastName = newPlayer.LastName;

//            ViewBag.Email = newPlayer.Email;

//            ViewBag.USAHockeyNum = newPlayer.USAHockeyNum;

//            ViewBag.DOB = newPlayer.DOB;

//            ViewBag.Address1 = newPlayer.Address1;

//            ViewBag.Address2 = newPlayer.Address2;

//            ViewBag.City = newPlayer.City;

//            ViewBag.State = newPlayer.State;

//            ViewBag.ZipCode = newPlayer.ZipCode;

//            ViewBag.Phone1 = newPlayer.Phone1;

//            ViewBag.Phone2 = newPlayer.Phone2;

//            ViewBag.Emergency1 = newPlayer.Emergency1;

//            ViewBag.Emergency2 = newPlayer.Emergency2;

//            ViewBag.YearsExp = newPlayer.YearsExp;

//            ViewBag.Level = newPlayer.Level;

//            ViewBag.Internet = newPlayer.Internet;

//            ViewBag.Referral = newPlayer.Referral;

//            ViewBag.Tournament = newPlayer.Tournament;

//            ViewBag.Other = newPlayer.Other;

//            ViewBag.LTP = newPlayer.LTP;

//            ViewBag.Tuesday = newPlayer.Tuesday;

//            ViewBag.Wednesday = newPlayer.Wednesday;

//            ViewBag.Stickhandling = newPlayer.Stickhandling;

//            ViewBag.Somerville = newPlayer.Somerville;

//            ViewBag.Games = newPlayer.Games;

//            ViewBag.Payment = paymentAmount;

//            ViewBag.PaymentType = paymentType;

//            ViewBag.PaymentAmount = paymentAmount;


//            //generate email to Player
//            EmailConfiguration emailConfig = new EmailConfiguration();
//            EmailManager emailManager = new EmailManager(EmailConfiguration.GetInstance());
//            String emailBody = "Thank you for submitting your registration for a NEWHL Program. ";


//            if (confirmedPlayer != null)
//            {
//                emailBody = " Your updated registration information will be displayed below." +
//                "\n" + "\n" + "First Name: " + newPlayer.FirstName + "\n" + "Last Name: " + newPlayer.LastName + "\n" + "Email Address: " + newPlayer.Email + "\n" +
//                "USA Hockey Number: " + newPlayer.USAHockeyNum + "\n" + "DOB: " + newPlayer.DOB + "\n" + "Address: " + newPlayer.Address1 + " " + newPlayer.Address2 + "\n" +
//                "City: " + newPlayer.City + "\n" + "State: " + newPlayer.State + "\n" + "Zip Code: " + newPlayer.ZipCode + "\n" + "Primary Phone: " + newPlayer.Phone1 + "\n" +
//                "Secondary Phone: " + newPlayer.Phone2 + "\n" + "Emergency Contacts: " + newPlayer.Emergency1 + ", " + newPlayer.Emergency2 + "\n" + "Years Experience: " + newPlayer.YearsExp + "\n" +
//                "Experience Level: " + newPlayer.Level + "\n" + "\n" + "Programs requested: " + "\n" + "Learn To Play (Monday): " + newPlayer.LTP + "Rec Skill (Tuesday): " + newPlayer.Tuesday + "\n" +
//                "C/D SKills (Wednesday): " + newPlayer.Wednesday + "\n" + "Stickhandling and Shooting Skills (Thursday): " + newPlayer.Stickhandling + "\n" +
//                "Mixed Level Skills (Somerville, Thursday PM): " + newPlayer.Somerville + "\n" + "Games (Friday): " + newPlayer.Games;

//                emailManager.SendEmail(emailConfig.FromAddress, newPlayer.Email, "Updated NEWHL Registration", emailBody);
//            }
//            else
//            {
//                //send error message to View
//            }


//            Decimal LTP_Price = 1;
//            ViewBag.LTP_Price = LTP_Price.ToString();

//            Decimal Tues_Price = 1;
//            ViewBag.Tuesday_Price = Tues_Price.ToString();

//            Decimal Wed_Price = 1;
//            ViewBag.Wednesday_Price = Wed_Price.ToString();

//            Decimal Stickhandling_Price = 1;
//            ViewBag.Stickhandling_Price = Stickhandling_Price.ToString();

//            Decimal Somerville_Price = 1;
//            ViewBag.Somerville_Price = Somerville_Price.ToString();

//            Decimal Games_Price = 1;
//            ViewBag.Games_Price = Games_Price.ToString();

//            Decimal Total_Price = 0;

//            if (confirmedPlayer.LTP == "yes")
//            {
//                Total_Price = Total_Price + LTP_Price;
//            }
//            if (confirmedPlayer.Tuesday == "yes")
//            {
//                Total_Price = Total_Price + Tues_Price;
//            }
//            if (confirmedPlayer.Wednesday == "yes")
//            {
//                Total_Price = Total_Price + Wed_Price;
//            }
//            if(confirmedPlayer.Stickhandling == "yes")
//            {
//                Total_Price = Total_Price + Stickhandling_Price;
//            }
//            if (confirmedPlayer.Somerville == "yes")
//            {
//                Total_Price = Total_Price + Somerville_Price;
//            }
//            if (confirmedPlayer.Games == "yes")
//            {
//                Total_Price = Total_Price + Games_Price;
//            }

//            ViewBag.Total_Price = Total_Price.ToString();
//            Decimal minimumPayment = Total_Price / 2 ;
//            ViewBag.minimumPayment = minimumPayment.ToString();

//            String strPaymentAmt = paymentAmount;
//            decimal decPaymentAmt = Convert.ToDecimal(strPaymentAmt);

//   /*         ActionResult retval = CallPayPal();
//            if (paymentType = "cc"  && hasPaid == false)
//            {
//                CallPayPal();

//            }
//            //{ then add ViewBag.ShowPayPal, show paypal button with instructions
//            //  OR
//            //   Call a function the will open a new view for PayPal and send return value that can be used in Code.
//            //return (View(ViewBag));}
//*/
//            //else if formaction = complete then
//                //save payment record, then
//                //this.Redirect("http://" + this.Request.Url.Authority + "/Programs/RegistrationComplete");
//            //else
//            //return View(model);

//            return (View(ViewBag));


//        }

        public ActionResult EnterPayment(AMFUserLogin confirmedPlayer, String formAction, String paymentPortion, String paymentAmount, String paymentType, String checkNumber)
        {
            ViewBag.PaymentAmount = paymentAmount;
            ViewBag.PaymentType   = paymentType;
            ViewBag.CheckNumber   = checkNumber;

            //need to enter payment info into database

            if (formAction == null)
            {
                return(this.View(ViewBag));
            }
            else
            {
                return(this.Redirect("http://" + this.Request.Url.Authority + "/Programs/RegistrationComplete"));
            }
        }
Beispiel #20
0
        public void UserRepositoryTestGetByid()
        {
            long         testLoginId = 1;
            AMFUserLogin foundItem   = this.RepositoryManager.UserRepository.GetById(1);

            if (foundItem == null)
            {
                string       testEmail = this.GenerateEmail(Guid.NewGuid().ToString("N"));
                AMFUserLogin newUser   = this.RepositoryManager.UserRepository.Save(this.CreateTestUser(testEmail));

                if (newUser != null)
                {
                    testLoginId = newUser.Id;
                }
            }

            foundItem = this.RepositoryManager.UserRepository.GetById(testLoginId);
            Assert.IsNotNull(foundItem);
        }
Beispiel #21
0
        public void ResetPassword(string userEmail, EmailConfiguration emailConfig)
        {
            AMFUserLogin targetUser = this.UserRepository.GetByEmail(userEmail);

            string emailBody = "A user was not found with that email address.  Please try again.";

            if (targetUser != null)
            {
                if (targetUser != null)
                {
                    string newPassword = targetUser.GenerateNewPassword();
                    emailBody = "Sorry you had a problem entering your password, your new password is " + newPassword;

                    this.UserRepository.Save(targetUser);
                }

                EmailManager emailManager = new EmailManager(emailConfig);
                emailManager.SendEmail(emailConfig.FromAddress, userEmail, "New Password", emailBody);
            }
        }
Beispiel #22
0
        public void ApproveAccess(string oauthToken)
        {
            try
            {
                HttpCookie authCookie            = Request.Cookies[FormsAuthentication.FormsCookieName];
                FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);

                AMFUserLogin currentUser = this.ServiceManager.UserService.GetUserById(int.Parse(ticket.Name));

                if (currentUser != null)
                {
                    this.CurrentPrincipal = new OAuthServerSecurityPrincipal(currentUser);
                    this.RedirectToClient(this.ServiceManager.TokenService.CreateVerifierAndAssociateUserInfo(oauthToken, currentUser), true);
                }
            }
            catch (Exception e)
            {
                LogManager.GetLogger().Error(e);
            }
        }
Beispiel #23
0
        /// <summary>
        /// Register a new user with the site
        /// </summary>
        /// <param name="registerModel">The incoming parameters used to register the user</param>
        /// <returns>The Registered user view</returns>
        public ActionResult Edit(RegisterModel registerModel)
        {
            AMFUserLogin registeredUser = null;

            if (registerModel != null)
            {
                registeredUser = this.ServiceManager.UserService.Update(registerModel.Id, registerModel.FirstName, registerModel.LastName, registerModel.Password);

                if (registeredUser != null)
                {
                    this.SetCurrentUser(registeredUser);
                }

                return(this.View("ProcessSignin", registeredUser));
            }
            else
            {
                return(this.View("Signin"));
            }
        }
        public static NewhlSecurityPrincipal ParseCookie(HttpCookieCollection cookies)
        {
            // Get the authentication cookie
            string                 cookieName = FormsAuthentication.FormsCookieName;
            HttpCookie             authCookie = cookies[cookieName];
            NewhlSecurityPrincipal retVal     = null;

            IServiceManager serviceManager = ServiceManagerBuilder.CreateServiceManager();

            if (authCookie != null)
            {
                if (authCookie.Value != string.Empty)
                {
                    try
                    {
                        // Get the authentication ticket
                        // and rebuild the principal & identity
                        FormsAuthenticationTicket authTicket =
                            FormsAuthentication.Decrypt(authCookie.Value);

                        AMFUserLogin currentUser = serviceManager.UserService.GetUserById(int.Parse(authTicket.Name));
                        retVal = new NewhlSecurityPrincipal(currentUser);
                    }
                    catch (Exception e)
                    {
                        retVal = new NewhlSecurityPrincipal(null);
                    }
                }
            }
            else
            {
                retVal = new NewhlSecurityPrincipal(null);
            }

            System.Threading.Thread.CurrentPrincipal = retVal;
            HttpContext.Current.User = retVal;

            return(retVal);
        }
Beispiel #25
0
        public ActionResult Edit(AMFUserLogin registerModel)
        {
            AMFUserLogin registeredUser = null;

            if (registerModel != null)
            {
                registeredUser = this.ServiceManager.UserService.Update(registerModel.Id, registerModel.FirstName, registerModel.LastName, registerModel.Email,
                                                                        registerModel.USAHockeyNum, registerModel.DOB, registerModel.Address1, registerModel.Address2, registerModel.City, registerModel.State, registerModel.ZipCode,
                                                                        registerModel.Phone1, registerModel.Phone2, registerModel.Emergency1, registerModel.Emergency2, registerModel.YearsExp, registerModel.Level, registerModel.Internet,
                                                                        registerModel.Referral, registerModel.Tournament, registerModel.Other);

                if (registeredUser != null)
                {
                    this.SetCurrentUser(registeredUser);
                }

                return(this.View("Manage", registeredUser));
            }
            else
            {
                return(this.View("Signin"));
            }
        }
Beispiel #26
0
        public AMFUserLogin Update(long userId, String firstName, String lastName, String email, String usaHockeyNum, String dOB, String address1, String address2, String city, String state, String zipCode, String phone1, String phone2, String emergency1, String emergency2, String yearsExp, PlayerLevel level, String internet, String referral, String tournament, String other)
        {
            AMFUserLogin retVal = this.UserRepository.GetById(userId);

            if (retVal == null)
            {
                retVal = this.UserRepository.GetByEmail(email);
            }

            if (retVal != null)
            {
                retVal.FirstName    = firstName;
                retVal.LastName     = lastName;
                retVal.Email        = email;
                retVal.USAHockeyNum = usaHockeyNum;
                retVal.DOB          = dOB;
                retVal.Address1     = address1;
                retVal.Address2     = address2;
                retVal.City         = city;
                retVal.State        = state;
                retVal.ZipCode      = zipCode;
                retVal.Phone1       = phone1;
                retVal.Phone2       = phone2;
                retVal.Emergency1   = emergency1;
                retVal.Emergency2   = emergency2;
                retVal.YearsExp     = yearsExp;
                retVal.Level        = level;
                retVal.Internet     = internet;
                retVal.Referral     = referral;
                retVal.Tournament   = tournament;
                retVal.Other        = other;

                retVal = this.UserRepository.Save(retVal);
            }

            return(retVal);
        }
Beispiel #27
0
        /// <summary>
        /// Register a new user with the site
        /// </summary>
        /// <param name="registerModel">The incoming parameters used to register the user</param>
        /// <returns>The Registered user view</returns>
        public ActionResult Register(RegisterModel registerModel)
        {
            AMFUserLogin registeredUser = null;

            if (registerModel != null)
            {
                registeredUser = this.ServiceManager.UserService.GetByEmail(registerModel.UserEmail);

                if (registeredUser == null)
                {
                    registeredUser = this.ServiceManager.UserService.Register(registerModel.UserEmail, registerModel.Password, registerModel.PasswordHint, registerModel.FirstName, registerModel.LastName);
                }
                else
                {
                    TokenModel model = new TokenModel()
                    {
                        Token = registerModel.OAuthToken
                    };
                    return(this.View("Signin", model));
                }
            }

            if (registeredUser != null)
            {
                this.SetCurrentUser(registeredUser);
                TokenModel model = new TokenModel()
                {
                    Token = registerModel.OAuthToken
                };
                return(this.View(model));
            }
            else
            {
                return(this.View("SignUp", new { oauthToken = registerModel.OAuthToken }));
            }
        }
Beispiel #28
0
 public void SendPlayerEmailConfiguration(string emailAddress, EmailConfiguration emailConfig, EmailManager emailManager, AMFUserLogin playerInfo)
 {
     if (!emailConfig.IsDebugMode)
     {
         string emailBody = "Your new registration information will be displayed below." + this.GenerateEmailDetails(playerInfo);
         emailManager.SendEmail(emailConfig.FromAddress, emailAddress, "New NEWHL Registration", emailBody);
     }
 }
Beispiel #29
0
 public void SendPlayerEmailConfiguration(string emailAddress, EmailConfiguration emailConfig, AMFUserLogin playerInfo)
 {
     this.SendPlayerEmailConfiguration(emailAddress, emailConfig, new EmailManager(EmailConfiguration.GetInstance()), playerInfo);
 }
Beispiel #30
0
 public void SendAdminNotificationEmail(string emailAddress, EmailConfiguration emailConfig, EmailManager emailManager, AMFUserLogin playerInfo)
 {
     if (!emailConfig.IsDebugMode)
     {
         string emailBody = "The following player registered for a NEWHL Program. Registration information details below. The request was sent at " + DateTime.Now.ToString() + this.GenerateEmailDetails(playerInfo);
         emailManager.SendEmail(emailConfig.FromAddress, emailAddress, "New NEWHL Registration", emailBody);
     }
 }