Пример #1
0
        public string createTempPass()
        {
            /*
             * TODO: la contraseña temporal debe ser creada de forma randomica
             * con el metodo: RandomString
             */
            string tempPass = PasswordServices.PasswordEncoder("a*2Ks1#P9");

            return(tempPass);
        }
Пример #2
0
        public string TryUpdate(UpdateCredentialsRequest request)
        {
            string msgValidation = null;
            var    context       = _context;

            var query = from user in context.Set <UserApp>()
                        .Where(u => u.userNicname == request.nickname)
                        select user;

            if (query.Count() > 0)
            {
                UserApp userFound       = query.Single();
                Boolean isValidPassword = PasswordServices.PasswordMatch(request.currentPass, userFound.userPassword);
                if (!isValidPassword)
                {
                    _logger.LogError("[USER NOT MATCH CREDENCIALS] nickname: " + request.nickname);
                    msgValidation = "Nombre de Usuario o Contraseña incorrecta.";
                }
                else if (!request.newPass.Equals(request.confirmNewPass))
                {
                    _logger.LogError("[NOT MATCH NEW PASSWORD WITH CONFIRMATION] nickname: " + request.nickname);
                    msgValidation = "La contraseña nueva no coincide con la ingresada posteriormente.";
                }
                else
                {
                    userFound.userPassword = PasswordServices.PasswordEncoder(request.newPass);
                    userFound = _userModelServices.update(userFound);
                    /*Actualización del Usuario a estado Activo*/
                    States       stateActive  = _statesModelServices.findByKeyword("S001");
                    StatesOfUser statesOfUser = _statesOfUserModelServices.findByUserAppId(userFound.UserAppId);
                    if (statesOfUser != null)
                    {
                        statesOfUser.ModifiedAt = DateTime.Now;
                        statesOfUser.StatesId   = stateActive.StatesId;
                        statesOfUser            = _statesOfUserModelServices.update(statesOfUser);
                    }
                    else
                    {
                        msgValidation = "El usuario no tiene asignado un Estado. Contáctese con soporte";
                    }
                }
            }
            else
            {
                _logger.LogError("[USER NOT FOUND] nickname: " + request.nickname);
                msgValidation = "Nombre de Usuario o Contraseña incorrecta.";
            }
            return(msgValidation);
        }