general_programacion | Unsorted

Telegram-канал general_programacion - Programacion

1160

Grupo general de programadores. Si te gusta el juego Cartas contra la Humanidad prueba @cclhbot. Para cualquier duda preguntad a @themarioga

Subscribe to a channel

Programacion

Oye los haters están al alza eeeh

Читать полностью…

Programacion

Buenas!! Esta skill para Copilot y Claude Code convierte al modelo en un tutor paciente que no te da la solución, sino las preguntas y pistas para que la descubras tú:
https://github.com/mateosg/aprendizaje-guiado

Espero sea de utilidad

Читать полностью…

Programacion

quizá ese método tampoco aporta nada ...

Читать полностью…

Programacion

ahora he metido otro if al principio, si el userCheck es null, envío excepción de BadCredentialsException, me faltaba eso

Читать полностью…

Programacion

es entendible, las funciones de autenticación suelen ser grandes, habría que ver la posiblidad de poner más métodos pero puedes poner esos if juntos con un and, El swich case está bien (creo que ya te dijeron eso)

Читать полностью…

Programacion

había puesto un trocito

Читать полностью…

Programacion

no

if !userToCheck
return

if...
else ...

Читать полностью…

Programacion

se ve más bonito asi

Читать полностью…

Programacion

lo mejor sería poner userToCheck en un guarda y mantener el resto

Читать полностью…

Programacion

        if (userToCheck.isLoginRetryBlocked()) {

if (over15Minuts) {
result = this.RETRY_TIME - Duration.between(insLastRetryLoginBefore, insNow).toMinutes();
throw new RetryNotAllowedException(String.valueOf(result));
} else {
resetRetryFailure(userToCheck);
}
}


cómo haces esto en un if?

Читать полностью…

Programacion

No lo veo mal, pero quizá ayude extraer en funciones más chicas y luego componer

Читать полностью…

Programacion

Esto puede ser un solo if

Читать полностью…

Programacion

jeejej claro, stripe me jode, aunque tengo una duda, si mi hosting y dns no son del territorio espanol y utilizo el meotod de pago web3, incluso datos de mi pais de origen, podre o no podre evadir el muerto.

Читать полностью…

Programacion

puede ser empresa o no estar en españita pero vamos puedes preguntarle a stripe 😂

Читать полностью…

Programacion

entiendo... y esa es la unica forma para poder usar stripe connect?

Читать полностью…

Programacion

Pues nop. Tú ves que yo gane algo con esto salvo algún hater? Pues eso..

Читать полностью…

Programacion

creo que lo vengo arrastrando desde el principio xD

Читать полностью…

Programacion

ahí quizá podría haber usado el isEmpty() de Optional, pero tendré que ahcer bastante refactor supongo, no sé ahora cuántas veces uso el método getEmployeeByUsername del employeeService

Читать полностью…

Programacion

bueno e, switch lo he metido ahora, para quitar un par de if, queda con mejor presencia xD

Читать полностью…

Programacion

ahora si podría simplificarlo metiendo métodos, pero creo que es más legible teniéndolo todo dentro de uno, ya existe resetRetryFailure(), que simplifica bastante este método

Читать полностью…

Programacion

    public ResponseEntity<Void> authenticate(String username, String password) {

EmployeeEntity userToCheck = this.employeeService.getEmployeeByUsername(username);

boolean over15Minuts = false;
Instant insNow = null;
Instant insLastRetryLoginBefore = null;
long result = 0;

if (userToCheck.getLastRetryLoginInstant() != null) {
insNow = Instant.now();
insLastRetryLoginBefore = userToCheck.getLastRetryLoginInstant();
over15Minuts = insNow.isBefore(insLastRetryLoginBefore.plus(this.RETRY_TIME, ChronoUnit.MINUTES));
}

if (userToCheck.isLoginRetryBlocked()) {

if (!over15Minuts)
resetRetryFailure(userToCheck);

result = this.RETRY_TIME - Duration.between(insLastRetryLoginBefore, insNow).toMinutes();
throw new RetryNotAllowedException(String.valueOf(result));
}

if (!passwordEncoder.matches(password, userToCheck.getPassword())) {
userToCheck.setRetryLoginCount(userToCheck.getRetryLoginCount() + 1);

switch (userToCheck.getRetryLoginCount()) {
case FIRST_BAD_LOGIN:
userToCheck.setLastRetryLoginInstant(Instant.now());
break;

case LAST_BAD_LOGIN:
userToCheck.setLoginRetryBlocked(true);
this.employeeService.saveEmployee(userToCheck);
result = this.RETRY_TIME - Duration.between(insLastRetryLoginBefore, insNow).toMinutes();
throw new RetryNotAllowedException(String.valueOf(result));
}

this.employeeService.saveEmployee(userToCheck);
throw new BadCredentialsException("Password incorrect");
}

resetRetryFailure(userToCheck);

Cookie cookie = jwtUtil.getNewCookie(jwtUtil.generateToken(username));

String tokenValue = JwtUtil.JWT_COOKIE_NAME + "=" + cookie.getValue()
+ "; HttpOnly; Secure; Path=/; Max-Age=3600";

return ResponseEntity.status(HttpStatus.FOUND)
.header(HttpHeaders.SET_COOKIE, tokenValue)
.header(HttpHeaders.LOCATION, UriParam.HOME.getName())
.build();

}


el código del método entero es este

Читать полностью…

Programacion

        if (userToCheck.isLoginRetryBlocked()) {

if (!over15Minuts)
resetRetryFailure(userToCheck);

result = this.RETRY_TIME - Duration.between(insLastRetryLoginBefore, insNow).toMinutes();
throw new RetryNotAllowedException(String.valueOf(result));
}

así?

Читать полностью…

Programacion

a to te voy a meter en una guarderia

Читать полностью…

Programacion

a mi me rompe el else

Читать полностью…

Programacion

Tanto para ganar legibilidad, como limpieza (menos anidación)

Читать полностью…

Programacion

Combina las dos expresiones con and y ya, no son condiciones tan complejas

Читать полностью…

Programacion

aclarando de tener una address o una cuenta en el exterior, con el objetivo de no mover ni hacer transferencia hacia espana, claro esta.

Читать полностью…

Programacion

Yo baneaba a alguien

Читать полностью…

Programacion

Menuda conversación de perros

Читать полностью…

Programacion

alguien de España que me ayude a aclarar una duda, por favor, para usar stripe connect es hobligado estar de alta como autonomo?

Читать полностью…
Subscribe to a channel