forked from Archives/Athou_commafeed
fix api key generation
This commit is contained in:
@@ -30,6 +30,10 @@ public abstract class GenericDAO<T extends AbstractModel> extends AbstractDAO<T>
|
|||||||
models.forEach(m -> persist(m));
|
models.forEach(m -> persist(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(T model) {
|
||||||
|
currentSession().merge(model);
|
||||||
|
}
|
||||||
|
|
||||||
public T findById(Long id) {
|
public T findById(Long id) {
|
||||||
return get(id);
|
return get(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor(onConstructor = @__({ @Inject }) )
|
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
|
||||||
@Singleton
|
@Singleton
|
||||||
public class UserREST {
|
public class UserREST {
|
||||||
|
|
||||||
@@ -208,7 +208,6 @@ public class UserREST {
|
|||||||
return Response.status(Status.FORBIDDEN).build();
|
return Response.status(Status.FORBIDDEN).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
user = userDAO.findById(user.getId());
|
|
||||||
user.setEmail(StringUtils.trimToNull(request.getEmail()));
|
user.setEmail(StringUtils.trimToNull(request.getEmail()));
|
||||||
if (StringUtils.isNotBlank(request.getPassword())) {
|
if (StringUtils.isNotBlank(request.getPassword())) {
|
||||||
byte[] password = encryptionService.getEncryptedPassword(request.getPassword(), user.getSalt());
|
byte[] password = encryptionService.getEncryptedPassword(request.getPassword(), user.getSalt());
|
||||||
@@ -218,7 +217,7 @@ public class UserREST {
|
|||||||
if (request.isNewApiKey()) {
|
if (request.isNewApiKey()) {
|
||||||
user.setApiKey(userService.generateApiKey(user));
|
user.setApiKey(userService.generateApiKey(user));
|
||||||
}
|
}
|
||||||
userDAO.saveOrUpdate(user);
|
userDAO.update(user);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user