1160
Grupo general de programadores. Si te gusta el juego Cartas contra la Humanidad prueba @cclhbot. Para cualquier duda preguntad a @themarioga
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
ahora he metido otro if al principio, si el userCheck es null, envío excepción de BadCredentialsException, me faltaba eso
Читать полностью…
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)
Читать полностью…
lo mejor sería poner userToCheck en un guarda y mantener el resto
Читать полностью…
if (userToCheck.isLoginRetryBlocked()) {
if (over15Minuts) {
result = this.RETRY_TIME - Duration.between(insLastRetryLoginBefore, insNow).toMinutes();
throw new RetryNotAllowedException(String.valueOf(result));
} else {
resetRetryFailure(userToCheck);
}
}
No lo veo mal, pero quizá ayude extraer en funciones más chicas y luego componer
Читать полностью…
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.
Читать полностью…
puede ser empresa o no estar en españita pero vamos puedes preguntarle a stripe 😂
Читать полностью…
entiendo... y esa es la unica forma para poder usar stripe connect?
Читать полностью…
Pues nop. Tú ves que yo gane algo con esto salvo algún hater? Pues eso..
Читать полностью…
creo que lo vengo arrastrando desde el principio xD
Читать полностью…
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
Читать полностью…
bueno e, switch lo he metido ahora, para quitar un par de if, queda con mejor presencia xD
Читать полностью…
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
Читать полностью…
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();
}
if (userToCheck.isLoginRetryBlocked()) {
if (!over15Minuts)
resetRetryFailure(userToCheck);
result = this.RETRY_TIME - Duration.between(insLastRetryLoginBefore, insNow).toMinutes();
throw new RetryNotAllowedException(String.valueOf(result));
}
Tanto para ganar legibilidad, como limpieza (menos anidación)
Читать полностью…
Combina las dos expresiones con and y ya, no son condiciones tan complejas
Читать полностью…
aclarando de tener una address o una cuenta en el exterior, con el objetivo de no mover ni hacer transferencia hacia espana, claro esta.
Читать полностью…
alguien de España que me ayude a aclarar una duda, por favor, para usar stripe connect es hobligado estar de alta como autonomo?
Читать полностью…