Ejemplo n.º 1
0
        public ActionResult Login(string redir, string user, string pass)
        {
            if (Request.HttpMethod.ToLowerInvariant() == "post")
            {
                AuthenticationLib authLib  = new AuthenticationLib();
                UserInfo          userInfo = authLib.Authenticate(user, pass);
                if (userInfo == null)
                {
                    CMSPageRequest page = _PageFactory.GetPage(Request, "x7") as CMSPageRequest;
                    page.Tag = new LoginModel
                    {
                        RedirectUrl = redir,
                        UserName    = user,
                        Error       = "Invalid User name or Password"
                    };

                    return(View("Login", page));
                }
                else if (!userInfo.Paid)
                {
                    CMSPageRequest page = _PageFactory.GetPage(Request, "x7") as CMSPageRequest;
                    page.Tag = new LoginModel
                    {
                        RedirectUrl = redir,
                        UserName    = user,
                        Error       = "Payment not processed yet. You will be able to login as soon as payment is received."
                    };

                    return(View("Login", page));
                }
                else
                {
                    //save as session
                    Session["user"] = userInfo;

                    if (string.IsNullOrWhiteSpace(redir))
                    {
                        return(Redirect("~/"));
                    }
                    else
                    {
                        //redirect to redir url
                        return(Redirect(redir));
                    }
                }
            }
            else
            {
                CMSPageRequest page = _PageFactory.GetPage(Request, "x7") as CMSPageRequest;
                page.Tag = new LoginModel
                {
                    RedirectUrl = redir
                };
                return(View("Login", page));
            }
        }
Ejemplo n.º 2
0
        internal override System.Web.Mvc.ActionResult handleStandardCMSPageRequest(CMSPageRequest pageRequest)
        {
            var auth = new AuthenticationLib();

            bool isTempUser = false;

            UserInfo user = Session["user"] as UserInfo;

            if (user == null)
            {
                string tempUserId = Session["tempIdForBirdList"] as string;
                if (!string.IsNullOrWhiteSpace(tempUserId))
                {
                    user       = auth.User(tempUserId);
                    isTempUser = true;
                }
            }

            if (user != null && pageRequest.Form["posting"] == "true")
            {
                var selectedBirdIds = pageRequest.Form.GetValues("bird");
                user.Birds = selectedBirdIds
                             .Select(
                    b => new BirdInfo
                {
                    XID = b
                })
                             .ToList();

                user.OtherBirds = pageRequest.Form["otherBirds"];
                lock (auth.SyncRoot)
                    auth.Save();
            }

            HashSet <string> birdIds = user != null?user.Birds
                                       .Select(
                b => b.XID)
                                       .ToHashSet() : new HashSet <string>();

            pageRequest.Tag = new BirdsModel
            {
                Birds      = birdIds,
                OtherBirds = user
                             .ToNullHelper()
                             .Propagate(
                    u => u.OtherBirds)
                             .Return(""),
                IsTempUser = isTempUser
            };

            return(base.handleStandardCMSPageRequest(pageRequest));
        }
Ejemplo n.º 3
0
        public ActionResult ChangePassword(string OPassword, string Password, string PasswordC)
        {
            CMSPageRequest page = _PageFactory.GetPage(Request, "x7") as CMSPageRequest;

            if (Request.HttpMethod.ToLowerInvariant() == "post")
            {
                OPassword = Request.Form["OPassword"];
                Password  = Request.Form["Password"];
                PasswordC = Request.Form["PasswordC"];

                var user = Session["user"] as Ingeniux.Runtime.Models.UserInfo;
                if (user == null)
                {
                    page.Tag = "Please login first in order to change password.";
                }
                else
                {
                    if (user.Password != OPassword)
                    {
                        page.Tag = "Current password is incorrect.";
                    }
                    else if (Password != PasswordC)
                    {
                        page.Tag = "Password confirmation doesn't match.";
                    }
                    else
                    {
                        if (Password.Length < 6)
                        {
                            page.Tag = "Password must be at least 6 characters.";
                        }

                        user.Password = Password;
                        AuthenticationLib auth = new AuthenticationLib();
                        auth.SignupOrUpdate(user, false);
                    }
                }

                if (page.Tag != null)
                {
                    return(View("ChangePassword", page));
                }
                else
                {
                    return(Redirect("~/"));
                }
            }

            return(View("ChangePassword", page));
        }
Ejemplo n.º 4
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine(Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"));

            #region AppSettings
            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json", true, true)
                                    .AddJsonFile("appsettings.Development.json", true, true)
                                    .Build();

            var tdxConfig = new TDXSettings();
            config.GetSection("TeamDynamixSettings").Bind(tdxConfig);

            var proxyConfig = new ProxySettings();
            config.GetSection("ProxySettings").Bind(proxyConfig);
            #endregion

            TDXEnvironment tDXEnvironment = new TDXEnvironment {
                ClientUrl            = tdxConfig.ClientURL,
                IsSandboxEnvironment = tdxConfig.IsSandboxEnvironment
            };

            AdminTokenParameters adminTokenParameters = new AdminTokenParameters {
                BEID           = tdxConfig.BEID,
                WebServicesKey = tdxConfig.WebServiceKey
            };

            AuthenticationLib authenticationLib = new AuthenticationLib();
            var JWT = await authenticationLib.GetAuthHeaderAsync(adminTokenParameters, tDXEnvironment);

            ImpactsLib    impactsLib    = new ImpactsLib();
            PrioritiesLib prioritiesLib = new PrioritiesLib();
            SourcesLib    sourcesLib    = new SourcesLib();

            var impacts = await impactsLib.GetTicketImpactsAsync(431, JWT, tDXEnvironment);

            var priorities = await prioritiesLib.GetTicketPrioritiesAsync(431, JWT, tDXEnvironment);

            var sources = await sourcesLib.GetTicketSourcesAsync(431, JWT, tDXEnvironment);

            //PeopleLib peopleLib = new PeopleLib();
            //var serg = await peopleLib.GetPersonLookupAsync("*****@*****.**", JWT, tDXEnvironment);

            //TicketLib ticketLib = new TicketLib();
            //Ticket ticket = new Ticket() {
            //    TypeID = 20999,
            //    Title = "TEST API IGNORE",
            //    AccountID = 48319,
            //    StatusID = 17950,
            //    PriorityID = 3371,
            //    RequestorUid = serg[0].UID
            //};

            //TicketCreateOptions ticketCreateOptions = new TicketCreateOptions() {
            //    AllowRequestorCreation = false,
            //    EnableNotifyReviewer = false,
            //    NotifyRequestor = false,
            //    NotifyResponsible = false
            //};

            //var myTestTicket = await ticketLib.CreateTicketAsync(ticket, 431, ticketCreateOptions, JWT, tDXEnvironment);

            //foreach(PropertyDescriptor descriptor in TypeDescriptor.GetProperties(myTestTicket)) {
            //    string name = descriptor.Name;
            //    object value = descriptor.GetValue(myTestTicket);
            //    Console.WriteLine("{0} = {1}", name, value);
            //}

            Console.ReadLine();
        }
Ejemplo n.º 5
0
        internal override System.Web.Mvc.ActionResult handleStandardCMSPageRequest(CMSPageRequest pageRequest)
        {
            //handle form post
            var isSignupPost = pageRequest.Form["signupPost"] == "1";

            if (isSignupPost)
            {
                var forms = pageRequest.Form;
                //handle sign up first
                UserInfo user = new UserInfo
                {
                    Name       = forms["Name"],
                    CoMembers  = forms["CoMembers"],
                    Address    = forms["Address"],
                    City       = forms["City"],
                    State      = forms["State"],
                    Zip        = forms["Zip"],
                    Phone      = forms["Phone"],
                    Email      = forms["Email"],
                    Occupation = forms["Occupation"],
                };

                bool isNewUser = forms["IsNewUser"] == "true";

                if (isNewUser)
                {
                    user.UserId   = forms["UserId"];
                    user.Password = forms["Password"];
                }
                else
                {
                    var sessionUser = Session["user"] as UserInfo;
                    sessionUser.Name       = user.Name;
                    sessionUser.CoMembers  = user.CoMembers;
                    sessionUser.Address    = user.Address;
                    sessionUser.City       = user.City;
                    sessionUser.State      = user.State;
                    sessionUser.Zip        = user.Zip;
                    sessionUser.Phone      = user.Phone;
                    sessionUser.Email      = user.Email;
                    sessionUser.Occupation = user.Occupation;

                    user = sessionUser;
                }

                AuthenticationLib auth = new AuthenticationLib();

                try
                {
                    auth.SignupOrUpdate(user, isNewUser);
                    pageRequest.Tag = isSignupPost;
                    //issue a temp id just allow birds list update
                    Session["tempIdForBirdList"] = user.UserId;
                }
                catch (UserExistException e)
                {
                    pageRequest.Tag = user.Name;
                }
                catch (Exception e)
                {
                    pageRequest.Tag = "Signup Error: " + e.Message;
                }
            }

            return(base.handleStandardCMSPageRequest(pageRequest));
        }