Пример #1
0
 private void PostLoginEvent()
 {
     if (!String.IsNullOrWhiteSpace(Txt_Username.Text) && !String.IsNullOrEmpty(Txt_Password.Password))
     {
         Txt_loginFailure.Visibility = Visibility.Hidden;
         UserLoginEventArgs args = new UserLoginEventArgs()
         {
             Username         = Txt_Username.Text,
             Password         = Txt_Password.Password,
             AutomaticLogin   = Chk_AutoLogin.IsChecked == true,
             RememberPassword = Chk_RememberPassword.IsChecked == true
         };
         OnLogin?.Invoke(this, args);
         loginInfo.Message = "正在登录...";
     }
     else if (String.IsNullOrWhiteSpace(Txt_Username.Text))
     {
         loginInfo.Message = "请输入用户名!";
         loginInfo.IsShown = true;
     }
     else if (String.IsNullOrEmpty(Txt_Password.Password))
     {
         loginInfo.Message = "请输入密码!";
         loginInfo.IsShown = true;
     }
 }
Пример #2
0
        /// <summary>
        /// Handles the EventArg passed.
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">EventArgs</param>
        public override void HandleEvent(object sender, EventArgs e)
        {
            if (e is UserLoginEventArgs)
            {
                UserLoginEventArgs userLoginEventArg = e as UserLoginEventArgs;
                if (userLoginEventArg != null)
                {
                    IEnumerable <ILoginView> views;
                    switch (userLoginEventArg.LoginResultType)
                    {
                    case Contract.Login.Enums.LoginResultType.Failed:
                        views = GetViews <ILoginView>();
                        foreach (ILoginView view in views)
                        {
                            view.LoginFailed(userLoginEventArg.Message);
                        }
                        break;

                    case Contract.Login.Enums.LoginResultType.Success:
                        views = GetViews <ILoginView>();
                        foreach (ILoginView view in views)
                        {
                            view.LoginSuccess(userLoginEventArg.Message);
                        }
                        break;
                    }
                }
            }
        }
Пример #3
0
        private void OnUserLogin(object sender, UserLoginEventArgs e)
        {
            int sid = e.Session.SessionId;

            if (InstanceBySID(sid) == null && AutoStart)
            {
                LaunchHelper(sid);
            }
        }
Пример #4
0
        void loginControl_Login(object sender, UserLoginEventArgs args)
        {
            Employee employee = args.Employee;

            if (employee != null)
            {
                orderEntryControl.Login(employee);
                loginControl.Visibility      = Visibility.Hidden;
                orderEntryControl.Visibility = Visibility.Visible;
            }
        }
Пример #5
0
        /// <summary>
        /// Creates a UserLoginEventArg
        /// </summary>
        /// <param name="loginResultType">LoginResult type.</param>
        /// <param name="message">Message from server.</param>
        /// <returns>Populated UserLoginEventArg</returns>
        private UserLoginEventArgs createUserLoginEventArg(
            LoginResultType loginResultType,
            string message)
        {
            UserLoginEventArgs userLoginEventHandler = new UserLoginEventArgs()
            {
                LoginResultType = loginResultType,
                Message         = message
            };

            return(userLoginEventHandler);
        }
Пример #6
0
 void _googleApiHelper_OnUserLogin(object sender, UserLoginEventArgs e)
 {
     _userAccount.Account = e.Account;
     _userAccount.Name    = e.User.name;
     _userAccount.Email   = e.User.email;
     _userAccount.Save();
     OnPropertyChanged(nameof(UserNameString));
     if (IsAccountValid)
     {
         LoadUserMaterials(_userAccount.Email);
     }
 }
Пример #7
0
        protected virtual async Task <(string email, string password)> OnUserLoginRequestedAsync()
        {
            var args = new UserLoginEventArgs();

            if (UserLoginRequested != null)
            {
                await UserLoginRequested(this, args);
            }

            if (args.IsCancelled)
            {
                throw new OperationCanceledException();
            }
            return(args.Email, args.Password);
        }
Пример #8
0
        public void FillInfo(UserLoginEventArgs args)
        {
            Txt_Username.Text              = args.Username;
            Txt_Password.Password          = args.Password;
            Chk_AutoLogin.IsChecked        = args.AutomaticLogin;
            Chk_RememberPassword.IsChecked = args.RememberPassword;

            new Task(() =>
            {
                Thread.Sleep(500);
                if (args.AutomaticLogin)
                {
                    this.Dispatcher.Invoke(new Action(PostLoginEvent));
                }
            }).Start();
        }
Пример #9
0
        partial void OnPasswordRecovery(UserLoginEventArgs e)
        {
            e.ContextRequest.SetParam("prevent-email", true);


            var template       = KstEmailTemplatesBR.Instance.GetBy(p => p.TitleKey == "recovery-password").FirstOrDefault();
            var layoutTemplate = KstEmailTemplatesBR.Instance.GetBy(p => p.TitleKey == "email-template", e.ContextRequest.CopySafe()).FirstOrDefault();

            if (template != null && template.Content != null)
            {
                string content = "Reestablece tu contraseña desde <a href=\"{URL}\">aquí</a>";
                if (template != null)
                {
                    content = template.Content;
                }
                string code = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);
                e.User.EmailCodeVerirication = code;
                SFS.Core.Security.BR.secUsersBR.Instance.UpdateAgile(e.User, e.ContextRequest, secUser.PropertyNames.EmailCodeVerirication);
                //content = content.Replace("{{NOMBRE-COMPLETO}}", e.User.FirstName + " " + e.User.LastName);
                string url = $"{e.ContextRequest.CurrentContext.ApplicationHome}/App/#/set-password/email/{e.User.Email}/code/{e.User.EmailCodeVerirication}";

                content = content.Replace("{{URL}}", url);
                content = content.Replace("{{CLICK-AQUI}}", $"<a href=\"{url}\">Click aquí</a>");
                //content = content.Replace(Environment.NewLine, "<br />");
                //content = content.Replace("\n", "<br />");
                string layoutContent = content;
                if (layoutTemplate != null)
                {
                    layoutTemplate.Content = layoutTemplate.Content.Replace("{{CONTENT}}", content);
                    layoutContent          = layoutTemplate.Content;
                }

                layoutContent = layoutContent.Replace("{{URL-LINK}}", $"{e.ContextRequest.CurrentContext.ApplicationHome}/App/#/set-password/email/{e.User.Email}/code/{e.User.EmailCodeVerirication}");

                SFS.Core.Net.Mail.SendMailAsync(e.User.Email, "Kstbio de contraseña", layoutContent, e.ContextRequest);
            }
        }
Пример #10
0
        partial void OnUserLoging(UserLoginEventArgs e)
        {
            ContextRequest contextRequest = new ContextRequest();
            string         userOrEmail    = e.Username;

            if (string.IsNullOrEmpty(userOrEmail))
            {
                userOrEmail = e.Email;
            }
            if (!string.IsNullOrEmpty(userOrEmail))
            {
                userOrEmail = userOrEmail.ToLower();
            }



            contextRequest.UseMode = "withPassword";
            var  userProxy  = KstProxyUsersBR.Instance.GetBy(p => (p.Username != null && p.Username.ToLower() == userOrEmail) || (p.Email != null && p.Email.ToLower() == userOrEmail), contextRequest).FirstOrDefault();
            bool findInCore = false;

            if (userProxy != null)
            {
                if (userProxy.Password == null)
                {
                    findInCore = true;
                }
                else if (e.Password == Decrypt(userProxy.Password))
                {
                    if (string.IsNullOrEmpty(userProxy.Username))
                    {
                        userProxy.Username = userProxy.Email;
                    }
                    // si existe el usuario
                    e.Result = new secUser()
                    {
                        GuidUser = userProxy.GuidUser, FirstName = userProxy.FirstName, LastName = userProxy.LastName, DisplayName = userProxy.DisplayName, Email = userProxy.Email, UserName = userProxy.Username
                    };
                }
                else
                {
                    findInCore = true;
                }
            }
            else
            {
                findInCore = true;
            }
            if (findInCore)
            {
                if (!string.IsNullOrEmpty(e.Password) && e.User == null)
                {
                    string     encryptedPassword = SFS.Core.Globals.Security.EncryptString(e.Password);
                    secUsersBR brUser            = new secUsersBR(true);
                    e.Result = brUser.GetBy(p => (p.LoweredUserName == userOrEmail && p.Password == encryptedPassword) || (p.Email.ToLower() == userOrEmail && p.Password == encryptedPassword), contextRequest).FirstOrDefault();
                }
            }
            if (userProxy != null)
            {
                //var customer = BR.ubiCustomersBR.Instance.GetBy(p => p.GuidUser == userProxy.GuidUser, contextRequest).FirstOrDefault();
                //if (customer != null)
                //{
                //    e.SetParam("GuidCustomer", customer.GuidCustomer);
                //    e.SetParam("NumAddresses", BR.ubiAddressesBR.Instance.GetCount(p => p.GuidCustomer == customer.GuidCustomer, contextRequest));

                //}
            }

            // e.PreventGlobalHtml = true;
        }