Exemple #1
0
        /// <summary>
        /// reset不需要原密码。分开两个方法是为了权限更方便控制
        /// </summary>
        /// <param name="passwordV"></param>
        /// <returns></returns>
        public async Task <ResponseResult> ReSetPassword(PasswordV passwordV)
        {
            var result = new ResponseResult();

            if (passwordV.NewPassword.IsNullOrWhiteSpace() ||
                passwordV.NewPassword1.IsNullOrWhiteSpace() ||
                !passwordV.NewPassword.Equals(passwordV.NewPassword1))
            {
                result.Code    = BusinessCode.Password_Params_Invalid;
                result.Message = nameof(BusinessCode.Password_Params_Invalid);
                return(result);
            }
            var user = await _userService.Get <UserDto>(i => i.Id == passwordV.UserId);

            if (user == null)
            {
                result.Message = nameof(BusinessCode.User_NotFound);
                result.Code    = BusinessCode.User_NotFound;
                return(result);
            }

            await _userService.Update <UserDto>(u => u.Id == passwordV.UserId, u => new UserDto {
                PassWord = passwordV.NewPassword
            });

            return(result);
        }
Exemple #2
0
        private void DetectInputLogin()
        {
            string Name    = Account.Text.Trim();
            string Passwd  = Password.Password;
            string PasswdV = PasswordV.Password;
            string Email   = EmailInput.Text.Trim();

            if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Passwd) || string.IsNullOrEmpty(PasswdV) || string.IsNullOrEmpty(Email))
            {
                if (string.IsNullOrEmpty(Name))
                {
                    Account.Focus(FocusState.Keyboard);
                }
                else if (string.IsNullOrEmpty(Passwd))
                {
                    Password.Focus(FocusState.Keyboard);
                }
                else if (string.IsNullOrEmpty(PasswdV))
                {
                    PasswordV.Focus(FocusState.Keyboard);
                }
                else if (string.IsNullOrEmpty(Email))
                {
                    EmailInput.Focus(FocusState.Keyboard);
                }
            }
            else if (Passwd != PasswdV)
            {
                StringResources stx = StringResources.Load("Error");
                ServerMessage.Text = stx.Str("PasswordMismatch");
                Password.Focus(FocusState.Keyboard);
            }
            else
            {
                ServerMessage.Text = "";

                IsPrimaryButtonEnabled
                              = IsSecondaryButtonEnabled
                              = Account.IsEnabled
                              = Password.IsEnabled
                              = PasswordV.IsEnabled
                              = EmailInput.IsEnabled
                              = false
                    ;

                this.Focus(FocusState.Pointer);

                IndicateLoad();

                RuntimeCache RCache = new RuntimeCache()
                {
                    EN_UI_Thead = true
                };
                RCache.POST(
                    Shared.ShRequest.Server
                    , Shared.ShRequest.Register(Name, Passwd, Email)
                    , RequestComplete, RequestFailed, false);
            }
        }
Exemple #3
0
        private void DetectInputLogin()
        {
            string CurrPasswd = CurrentPassword.Password;
            string NewPasswd  = Password.Password;
            string PasswdV    = PasswordV.Password;

            if (string.IsNullOrEmpty(CurrPasswd) || string.IsNullOrEmpty(NewPasswd) || string.IsNullOrEmpty(PasswdV))
            {
                if (string.IsNullOrEmpty(CurrPasswd))
                {
                    CurrentPassword.Focus(FocusState.Keyboard);
                }
                else if (string.IsNullOrEmpty(NewPasswd))
                {
                    Password.Focus(FocusState.Keyboard);
                }
                else if (string.IsNullOrEmpty(PasswdV))
                {
                    PasswordV.Focus(FocusState.Keyboard);
                }
            }
            else if (NewPasswd != PasswdV)
            {
                StringResources stx = StringResources.Load("Error");
                ServerMessage.Text = stx.Str("PasswordMismatch");
                Password.Focus(FocusState.Keyboard);
            }
            else
            {
                ServerMessage.Text = "";

                IsPrimaryButtonEnabled
                            = IsSecondaryButtonEnabled
                            = CurrentPassword.IsEnabled
                            = Password.IsEnabled
                            = PasswordV.IsEnabled
                            = false
                    ;

                this.Focus(FocusState.Pointer);

                IndicateLoad();

                RuntimeCache RCache = new RuntimeCache()
                {
                    EN_UI_Thead = true
                };
                RCache.POST(
                    Shared.ShRequest.Server
                    , Shared.ShRequest.ChangePassword(CurrPasswd, NewPasswd)
                    , RequestComplete, RequestFailed, false);
            }
        }
        private async void registrujNovog(object obj)
        {
            //IME VALIDACIJA
            if (uIme.Length < 3)
            {
                ImeV = "Ime je prekratko!";
                NotifyPropertyChanged("ImeV");
            }
            else
            {
                ImeV = "";
                NotifyPropertyChanged("ImeV");
            }

            //MAIL VALIDACIJA
            Regex regx  = new Regex(@"^([\w\.\-]+)@([\w\-]+)([\w\.\-]+)$");
            Match match = regx.Match(uMail);

            if (!match.Success)
            {
                MailV = "Mail nije validan!";
                NotifyPropertyChanged("MailV");
            }
            else
            {
                MailV = "";
                NotifyPropertyChanged("MailV");
            }

            //PREZIME VALIDACIJA
            if (uPrezime.Length < 3)
            {
                PrezimeV = "Prezime je prekratko!";
                NotifyPropertyChanged("PrezimeV");
            }
            else
            {
                PrezimeV = "";
                NotifyPropertyChanged("PrezimeV");
            }
            //password validacija
            if (uPassword.Length < 5)
            {
                PasswordV = "5 kraktera min!";
                NotifyPropertyChanged("PasswordV");
            }
            else
            {
                PasswordV = "";
                NotifyPropertyChanged("PasswordV");
            }

            //POTVRDA PASSWORD

            if (uPasswordPotvrda.Length < 5)
            {
                PotvrdaV = "5 kraktera min!";
                NotifyPropertyChanged("PotvrdaV");
            }
            else if (uPasswordPotvrda.Length >= 5 && uPasswordPotvrda != uPassword)
            {
                PotvrdaV = "Šire nisu jednake!";
                NotifyPropertyChanged("PotvrdaV");
            }
            else
            {
                PotvrdaV = "";
                NotifyPropertyChanged("PotvrdaV");
            }

            //prebivaliste
            if (uPrebivaliste.Length < 3)
            {
                PrebivalisteV = "3 kraktera min!";
                NotifyPropertyChanged("PrebivalisteV");
            }
            else
            {
                PrebivalisteV = "";
                NotifyPropertyChanged("PrebivalisteV");
            }

            if (ImeV.Equals("") && PrezimeV.Equals("") && MailV.Equals("") && PasswordV.Equals("") && PotvrdaV.Equals("") && PrebivalisteV.Equals(""))
            {
                ima = false;

                using (var db = new KorisnikDbContext())
                {
                    korisnici = db.Korisnici.ToList();

                    var contact = new Korisnik
                    {
                        Ime     = uIme,
                        Prezime = uPrezime,
                        Sifra   = uPassword,
                        Email   = uMail,
                        Slika   = uploadSlika
                    };

                    for (int i = 0; i < korisnici.Count; i++)
                    {
                        if (korisnici[i].Email.Equals(uMail))
                        {
                            var dijalog = new Windows.UI.Popups.MessageDialog(
                                "Korisnik sa tim mailom je već registrovan. ", "Poruka");


                            dijalog.Commands.Add(new Windows.UI.Popups.UICommand("OK")
                            {
                                Id = 0
                            });
                            dijalog.Commands.Add(new Windows.UI.Popups.UICommand("Cancel")
                            {
                                Id = 1
                            });

                            dijalog.DefaultCommandIndex = 0;
                            dijalog.CancelCommandIndex  = 1;

                            var rezultat = await dijalog.ShowAsync();

                            //reset polja za unos
                            uIme             = string.Empty;
                            uPassword        = string.Empty;
                            uMail            = string.Empty;
                            uPrebivaliste    = string.Empty;
                            uVozacka         = false;
                            uPasswordPotvrda = string.Empty;
                            uPrezime         = string.Empty;
                            uUpload          = "Upload";

                            ima = true;

                            break;
                        }
                    }

                    if (!ima)
                    {
                        db.Korisnici.Add(contact);

                        db.SaveChanges();

                        App.ImeLogIn = uIme;
                        App.Mail     = uMail;

                        //reset polja za unos
                        //reset polja za unos
                        uIme             = string.Empty;
                        uPassword        = string.Empty;
                        uMail            = string.Empty;
                        uPrebivaliste    = string.Empty;
                        uVozacka         = false;
                        uPasswordPotvrda = string.Empty;
                        uPrezime         = string.Empty;
                        uUpload          = "Upload";

                        var dialog = new Windows.UI.Popups.MessageDialog(
                            "Uspješna registracija. ", "Poruka");


                        dialog.Commands.Add(new Windows.UI.Popups.UICommand("OK")
                        {
                            Id = 0
                        });
                        dialog.Commands.Add(new Windows.UI.Popups.UICommand("Cancel")
                        {
                            Id = 1
                        });

                        dialog.DefaultCommandIndex = 0;
                        dialog.CancelCommandIndex  = 1;

                        var result = await dialog.ShowAsync();
                    }
                }
            }
        }