コード例 #1
0
ファイル: MembershipProvider.cs プロジェクト: ndrmc/cats-hub
        public override MembershipUser CreateUser(string username, string password, string email,
                                                  string passwordQuestion, string passwordAnswer, bool isApproved,
                                                  object providerUserKey, out MembershipCreateStatus status)
        {
            var user = new UserProfile();

            user.ActiveInd                = true;
            user.UserName                 = username;
            user.Email                    = email;
            user.Password                 = MD5Hashing.MD5Hash(password);
            user.FirstName                = " ";
            user.LastName                 = " ";
            user.LockedInInd              = false;
            user.LanguageCode             = "en";
            user.DefaultTheme             = "vista";
            user.DatePreference           = "en";
            user.PreferedWeightMeasurment = "MT";



            try
            {
                //TODO:More refactoring required
                repository.UserProfileRepository.Add(user);
                status = MembershipCreateStatus.Success;
                return(GetMembershipUser(user));
            }
            catch (Exception e)
            {
                status = MembershipCreateStatus.ProviderError;
            }

            return(null);
        }
コード例 #2
0
ファイル: MembershipProvider.cs プロジェクト: reerp/REERPE
        // TODO: Remove the context here.
        public override bool ValidateUser(string username, string password)
        {
            var userProfileService =
                (IUserProfileService)DependencyResolver.Current.GetService(typeof(IUserProfileService));
            string      pass = MD5Hashing.MD5Hash(password);
            UserProfile user = userProfileService.FindBy(u => u.UserName == username && u.Password == pass &&
                                                         !u.LockedInInd && u.ActiveInd).SingleOrDefault();

            return((user != null) ? true : false);
        }
コード例 #3
0
ファイル: MembershipProvider.cs プロジェクト: ndrmc/cats-hub
        // TODO: Remove the context here.
        public override bool ValidateUser(string username, string password)
        {
            var         entities = new CTSContext();
            string      pass     = MD5Hashing.MD5Hash(password);
            UserProfile user     = (from u in entities.UserProfiles
                                    where u.UserName == username && u.Password == pass &&
                                    !u.LockedInInd && u.ActiveInd
                                    select u).SingleOrDefault();

            return((user != null) ? true : false);
        }
コード例 #4
0
ファイル: AdminController.cs プロジェクト: ndrmc/cats-hub
        public virtual ActionResult Create(UserProfile userprofile)
        {
            if (ModelState.IsValid)
            {
                userprofile.Password = MD5Hashing.MD5Hash(userprofile.Password);
                _userProfileService.AddUserProfile(userprofile);
                return(Json(new { success = true }));
            }

            ViewBag.UserProfileID = new SelectList(_userRoleService.GetAllUserRole(), "UserRoleID", "UserRoleID", userprofile.UserProfileID);
            return(PartialView("Users/Create", userprofile));
        }
コード例 #5
0
ファイル: AccountController.cs プロジェクト: nathnael/cats
        public ActionResult ForgetPassword(ForgotPasswordModel model)
        {
            if (ModelState.IsValid)
            {
                if (_userProfileService.ChangePassword(model.UserProfilID, MD5Hashing.MD5Hash(model.Password)))
                {
                    _forgetPasswordRequestService.InvalidateRequest(model.UserProfilID);
                }

                return(RedirectToAction("LogOn"));
            }
            return(View("ForgetPassword", model));
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: sebartyr/EPIcFightsLauncher
        private void button1_Click(object sender, EventArgs e)
        {
            //Console.WriteLine(login.Text);
            //onsole.WriteLine(password.Text);
            if (login.Text != "" && password.Text != "")
            {
                erreur.Text = "Connexion...";
                Connexion connexion = new Connexion(login.Text, MD5Hashing.MD5Hash(password.Text));
                string    result    = connexion.Connect();
                //Console.WriteLine(result);

                switch (result)
                {
                case "erreur_connexion":
                    erreur.Text = "Impossible de se connecter au serveur";
                    break;

                case "erreur_log_or_pass1":
                    erreur.Text = "Veuillez entrer correctement vos infos";
                    break;

                case "erreur_log_or_pass2":
                    erreur.Text = "Le login ou le mot de passe est erroné";
                    break;

                default:
                    try
                    {
                        erreur.Text = "Connecté...";

                        Process P = Process.Start("jeu_xna.exe", result);
                        Application.Exit();
                    }
                    catch
                    {
                        erreur.Text = "Une erreur s'est produite";
                    }
                    break;
                }
            }
            else
            {
                //Console.WriteLine(0);
                //erreur.Text = "0";
                Process P = Process.Start("jeu_xna.exe", "0");
                Application.Exit();
            }
        }
コード例 #7
0
ファイル: MembershipProvider.cs プロジェクト: ndrmc/cats-hub
        public override bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            if (ValidateUser(username, oldPassword))
            {
                var         context = new CTSContext();
                UserProfile user    = context.UserProfiles.Where(p => p.UserName == username).SingleOrDefault();
                if (user != null)
                {
                    user.Password = MD5Hashing.MD5Hash(newPassword);
                    context.SaveChanges();
                    return(true);
                }
            }

            return(false);
        }
コード例 #8
0
ファイル: MembershipProvider.cs プロジェクト: reerp/REERPE
        public override bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            if (ValidateUser(username, oldPassword))
            {
                var userProfileService =
                    (IUserProfileService)DependencyResolver.Current.GetService(typeof(IUserProfileService));
                UserProfile user = userProfileService.FindBy(p => p.UserName == username).SingleOrDefault();
                if (user != null)
                {
                    user.Password = MD5Hashing.MD5Hash(newPassword);
                    userProfileService.EditUserProfile(user);
                    return(true);
                }
            }

            return(false);
        }
コード例 #9
0
ファイル: AccountController.cs プロジェクト: nathnael/cats
        public ActionResult ForgetPasswordRequest(ForgotPasswordRequestModel model)
        {
            if (ModelState.IsValid)
            {
                UserProfile profile = _userProfileService.GetUser(model.UserName);
                if (profile != null && !profile.LockedInInd)
                {
                    ForgetPasswordRequest req = new ForgetPasswordRequest()
                    {
                        Completed     = false,
                        ExpieryDate   = DateTime.Now.AddMonths(2),
                        GeneratedDate = DateTime.Now,
                        RequestKey    = MD5Hashing.MD5Hash(Guid.NewGuid().ToString()),
                        UserProfileID = profile.UserProfileID
                    };
                    if (_forgetPasswordRequestService.AddForgetPasswordRequest(req))
                    {
                        string to      = profile.Email;
                        string subject = "Password Change Request";
                        string link    = Request.Url.Host + "/Account/ForgetPassword/?key=" + req.RequestKey;
                        string body    = string.Format(@"Dear {1}
                                                            <br /><br />
                                                        A password reset request has been submitted for your DRMFSS - CTS account. If you submitted this password reset request, please follow the following link. 
                                                        <br /><br />
                                                        <a href='{0}'>Please Follow this Link</a> <br />
                                                        <br /><br />
                                                        Please ignore this message if the password request was not submitted by you. This request will expire in 24 hours.
                                                        <br /><br />
                                                       Thank you,<br />
                                                       Administrator.
                                                        ", link, profile.GetFullName());

                        try
                        {
                            // Read the configuration table for smtp settings.

                            string from     = _settingService.GetSettingValue("SMTP_EMAIL_FROM");
                            string smtp     = _settingService.GetSettingValue("SMTP_ADDRESS");
                            int    port     = Convert.ToInt32(_settingService.GetSettingValue("SMTP_PORT"));
                            string userName = _settingService.GetSettingValue("SMTP_USER_NAME");
                            string password = _settingService.GetSettingValue("SMTP_PASSWORD");
                            // send the email using the utilty method in the shared dll.
                            SendMail mail = new SendMail(from, to, subject, body, null, true, smtp, userName, password, port);
                            return(RedirectToAction("ConfirmPasswordChange"));
                        }
                        catch (Exception e)
                        {
                            ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again.";
                        }
                    }
                    else
                    {
                        ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again.";
                    }
                }
                else
                {
                    ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again.";
                }
            }
            return(View("ForgetPasswordRequest", model));
        }
コード例 #10
0
ファイル: AccountController.cs プロジェクト: nathnael/cats
        public ActionResult ForgetPasswordRequest(ForgetPasswordRequestModel model)
        {
            if (ModelState.IsValid)
            {
                var user = _userAccountService.GetUserDetail(model.UserName);
                if (user != null)
                {
                    var forgetPasswordRequest = new ForgetPasswordRequest()
                    {
                        Completed     = false,
                        ExpieryDate   = DateTime.Now.AddMonths(2),
                        GeneratedDate = DateTime.Now,

                        RequestKey    = MD5Hashing.MD5Hash(Guid.NewGuid().ToString()),
                        UserProfileID = user.UserProfileID

                                        //RequestKey = MD5Hashing.MD5Hash(Guid.NewGuid().ToString()),
                                        //UserAccountID = user.UserAccountId
                    };
                    if (_forgetPasswordRequestService.AddForgetPasswordRequest(forgetPasswordRequest))
                    {
                        string to          = user.Email;
                        string subject     = "Password Change Request";
                        var    callbackUrl = Url.Action("ForgetPassword", "Account", new { key = forgetPasswordRequest.RequestKey }, protocol: Request.Url.Scheme);

                        //string link = "localhost:" + Request.Url.Port + "/Account/ForgetPassword/?key=" + forgetPasswordRequest.RequestKey;
                        string body = string.Format(@"Dear {1}
                                                            <br /><br />
                                                        A password reset request has been submitted for your Email account. If you submitted this password reset request, please follow the following link. 
                                                        <br /><br />
                                                        <a href='{0}'>Please Follow this Link</a> <br />
                                                        <br /><br />
                                                        Please ignore this message if the password request was not submitted by you. This request will expire in 24 hours.
                                                        <br /><br />
                                                        Thank you,<br />
                                                        Administrator.
                                                        ", callbackUrl, user.UserName);
                        try
                        {
                            // Read the configuration table for smtp settings.

                            string from     = _settingService.GetSettingValue("SMTP_EMAIL_FROM");
                            string smtp     = _settingService.GetSettingValue("SMTP_ADDRESS");
                            int    port     = Convert.ToInt32(_settingService.GetSettingValue("SMTP_PORT"));
                            string userName = _settingService.GetSettingValue("SMTP_USER_NAME");
                            string password = _settingService.GetSettingValue("SMTP_PASSWORD");
                            // send the email using the utilty method in the shared dll.
                            Cats.Helpers.SendMail mail = new Helpers.SendMail(from, to, subject, body, null, true, smtp, userName, password, port);

                            ViewBag.ErrorMessage   = "Email has been sent to your email Address.";
                            TempData["ModelState"] = ViewBag.ErrorMessage;
                            return(RedirectToAction("ConfirmPasswordChange"));
                        }
                        catch (Exception e)
                        {
                            ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again.";
                        }
                    }

                    ViewBag.ErrorMessage = "Internal Error....";
                }

                ViewBag.ErrorMessage = "Invalid User Name " + model.UserName;
            }
            return(View());
        }