Beispiel #1
0
        private void acceptButton_Click(object sender, EventArgs e)
        {
            acepto = true;

            if (rolComboBox.SelectedItem != null)
            {
                Rol rol = UsuarioLogeado.Instance.Rol = (Rol)rolComboBox.SelectedItem;

                UsuarioLogeado.Instance.Rol.funcionalidades = AppLogin.traerFuncionalidades();

                AppLogin.cargarUsuario();

                //setea el nombre de la persona o del rol si no tuviera una asociada
                if (rol.nombre == "Profesional" || rol.nombre == "Afiliado")
                {
                    pantallaPrincipal.setearLogeo(UsuarioLogeado.Instance.Persona.nombre.ToUpper() + " " + UsuarioLogeado.Instance.Persona.apellido.ToUpper());
                }
                else
                {
                    pantallaPrincipal.setearLogeo(rol.nombre);
                }

                pantallaPrincipal.habilitarFuncionalidades();
            }
            else
            {
                MessageBox.Show("El sistema no tiene guardado ningún rol para este usuario. Contacte a su administrador.");
            }

            AsistenteVistas.volverAPadreYCerrar(pantallaPrincipal, this);
        }
Beispiel #2
0
        public ActionResult Index(AppLogin login)
        {
            if (this.ModelState.IsValid)
            {
                DBLoginRepository  loginRepository  = new DBLoginRepository(this.DatabaseContext);
                DBEditorRepository editorRepository = new DBEditorRepository(this.DatabaseContext);

                DBEditor editor = editorRepository.Find(login.Username);

                if (editor != null && login.Username == editor.Username && PasswordHasher.Hash(login.Password, editor.PasswordSalt) == editor.PasswordHash)
                {
                    DBLogin dBLogin = new DBLogin()
                    {
                        IDEditor = editor.ID, UserAgent = Request.UserAgent, UserIP = IPObtainer.GetIP(), UTCLogoutTime = DateTime.UtcNow.AddMinutes(10)
                    };
                    loginRepository.Add(dBLogin, true);
                    this.Session["authorized"] = dBLogin;
                    return(RedirectToAction("Index", "Admin"));
                }
                else
                {
                    return(View()); //neexistuje nebo nesedí přihlašovací údaje
                }
            }
            return(View());
        }
Beispiel #3
0
        bool acepto = false; //variable que sabe si se presionó en aceptar, no se puede logear sin elegir un rol ni cancelar la ventana

        public ElegirRol(PantallaPrincipal padre)
        {
            InitializeComponent();
            this.pantallaPrincipal = padre;

            rolComboBox.DataSource    = AppLogin.traerRoles(); //trae los roles del usuario
            rolComboBox.DisplayMember = "nombre";              //los muestra por nombre
        }
Beispiel #4
0
        /// <summary>
        /// Generates salt and hashes password
        /// </summary>
        /// <param name="appLogin"></param>
        /// <returns>AppLogin with salt and hashed password</returns>
        public AppLogin PrepareAppLogin(AppLogin appLogin)
        {
            var result = appLogin;
            var salt   = GenerateRandomSalt();

            result.Password = GetHash(salt, appLogin.Password);
            result.Salt     = salt;
            result.GuId     = Guid.NewGuid().ToString();
            return(result);
        }
        private UserInfoViewModel GenerateUserInfo(AppLogin appLogin)
        {
            var person           = appLogin.Person;
            var currentTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            var profile          = new ProfileViewModel();

            profile.Id            = person.Id;
            profile.Firstname     = person.FirstName;
            profile.Lastname      = person.LastName;
            profile.Authorization = new AuthorizationViewModel()
            {
                GuId = appLogin.GuId
            };
            var homeAddress = person.PersonalAddresses.AsQueryable().Where(a => a.GetType() == typeof(PersonalAddress)).SingleOrDefault();

            if (homeAddress != null)
            {
                profile.HomeLatitude  = homeAddress.Latitude;
                profile.HomeLongitude = homeAddress.Longitude;
            }
            profile.Employments = new List <EmploymentViewModel>();
            foreach (var employment in person.Employments.Where(x => x.StartDateTimestamp < currentTimestamp && (x.EndDateTimestamp > currentTimestamp || x.EndDateTimestamp == 0)))
            {
                profile.Employments.Add(new EmploymentViewModel()
                {
                    EmploymentPosition = employment.Position,
                    EndDateTimestamp   = employment.EndDateTimestamp,
                    Id    = employment.Id,
                    ManNr = employment.EmploymentId,
                    StartDateTimestamp = employment.StartDateTimestamp,
                    OrgUnit            = new OrgUnitViewModel()
                    {
                        OrgId             = employment.OrgUnitId,
                        FourKmRuleAllowed = employment.OrgUnit.HasAccessToFourKmRule
                    }
                });
            }

            var ui = new UserInfoViewModel();

            ui.profile = profile;
            ui.rates   = new List <RateViewModel>();
            foreach (var rate in rateRepo.AsQueryable().Where(x => x.Year == DateTime.Now.Year && x.Active).ToList())
            {
                ui.rates.Add(new RateViewModel()
                {
                    Id          = rate.Id,
                    Description = rate.Type.Description,
                    Year        = rate.Year.ToString()
                });
            }
            return(ui);
        }
 public LoginPageViewModel()
 {
     try
     {
         login   = new AppLogin();
         DoLogin = new Command(DoLoginoperation);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Beispiel #7
0
        public AppLogin SyncToDmz(AppLogin appLogin)
        {
            var encryptedLogin = Encryptor.EncryptAppLogin(appLogin);
            var dmzLogin       = new UserAuth
            {
                UserName  = encryptedLogin.UserName,
                GuId      = encryptedLogin.GuId,
                Password  = encryptedLogin.Password,
                ProfileId = encryptedLogin.PersonId,
                Salt      = encryptedLogin.Salt
            };

            _dmzUserRepository.Insert(dmzLogin);
            _dmzUserRepository.Save();

            return(encryptedLogin);
        }
Beispiel #8
0
        public AppLogin SyncToDmz(AppLogin appLogin)
        {
            var _dmzAuthRepo = new GenericDmzRepository <UserAuth>(new DmzContext());

            var encryptedLogin = Encryptor.EncryptAppLogin(appLogin);
            var dmzLogin       = new UserAuth
            {
                UserName  = encryptedLogin.UserName,
                GuId      = encryptedLogin.GuId,
                Password  = encryptedLogin.Password,
                ProfileId = encryptedLogin.PersonId,
                Salt      = encryptedLogin.Salt
            };

            _dmzAuthRepo.Insert(dmzLogin);
            _dmzAuthRepo.Save();

            return(encryptedLogin);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.UrlReferrer != null)
            {
                QueryParameter queryParam = new QueryParameter(Request);

                if (queryParam.Parameter.ContainsKey("USERNAME") && queryParam.Parameter.ContainsKey("PASSWORD"))
                {
                    if (AppSession.GetSession("USER_ID") == null)
                    {
                        QueryParameter loginParam = new QueryParameter();
                        loginParam.Add("USERNAME", queryParam["USERNAME"]);
                        loginParam.Add("PASSWORD", queryParam["PASSWORD"]);
                        QueryResult queryResult = AppLogin.Login(HttpContext.Current, loginParam);
                    }
                    queryParam.Remove("USERNAME");
                    queryParam.Remove("PASSWORD");
                }
                AppSession.SetSession("REQUEST_DATA", queryParam.Parameter);
                Response.Redirect(Request.ApplicationPath);
            }
        }
Beispiel #10
0
        private void acceptButton_Click(object sender, EventArgs e)
        {
            //cuando se intenta logear se devuelve un codigo que son los intentos o si no es de 1 a 3 es un codigo de error
            int n_intentos = AppLogin.intentarLogear(usrNameTextBox.Text, passTextBox.Text);

            //se acciona en base al intento de logeo (y el codigo o veces intentadas en n_intentos)
            if (0 == n_intentos)
            {
                UsuarioLogeado.Instance.UserName = usrNameTextBox.Text;

                AsistenteVistas.mostrarNuevaVentana(new ElegirRol(pantallaPrincipal), this);
            }
            else
            {
                if (n_intentos == -1)
                {
                    MessageBox.Show("...error conectando con la base de datos...");
                }
                else if (n_intentos < 3)
                {
                    MessageBox.Show("Contraseña erronea. Le quedan " + (3 - n_intentos) + " intentos.");
                }
                else if (n_intentos == 3)
                {
                    MessageBox.Show("Contraseña erronea. Se procederá a deshabilitar su usuario por seguridad.");
                }
                else if (n_intentos == 4)
                {
                    MessageBox.Show("Su usuario se encuentra deshabilitado por razones de seguridad. " +
                                    "Consulte con su administrador para volver a habilitarlo.");
                }
                else if (n_intentos == 5)
                {
                    MessageBox.Show("No existe el usuario ingresado en el sistema");
                }
            }
        }
 public static AppLogin DecryptAppLogin(AppLogin appLogin)
 {
     appLogin.GuId     = StringCipher.Decrypt(appLogin.GuId, EncryptKey);
     appLogin.UserName = StringCipher.Decrypt(appLogin.UserName, EncryptKey);
     return(appLogin);
 }
Beispiel #12
0
        // 登陆

        /// <summary>
        /// The post.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="BaseResult"/>.
        /// </returns>
        public BaseResult POST(AppLogin request)
        {
            return(this.AppApiManager.AppLogin(request));
        }
 public static AppLogin EncryptAppLogin(AppLogin appLogin)
 {
     appLogin.GuId     = StringCipher.Encrypt(appLogin.GuId, EncryptKey);
     appLogin.UserName = StringCipher.Encrypt(appLogin.Person.Initials, EncryptKey);
     return(appLogin);
 }