recover password (wip)

This commit is contained in:
Athou
2013-05-20 21:53:13 +02:00
parent 17ac0432b2
commit 515cc4c0dd
16 changed files with 409 additions and 89 deletions

View File

@@ -226,12 +226,13 @@ public class FeedREST extends AbstractResourceREST {
FeedInfo info = (FeedInfo) fetchFeed(url).getEntity();
try {
feedSubscriptionService.subscribe(getUser(), info.getUrl(),
req.getTitle(), category);
req.getTitle(), category);
} catch (Exception e) {
log.info("Failed to subscribe to URL {}: {}", url, e.getMessage());
return Response.status(Status.SERVICE_UNAVAILABLE).entity(
"Failed to subscribe to URL " + url + ": " + e.getMessage()
).build();
return Response
.status(Status.SERVICE_UNAVAILABLE)
.entity("Failed to subscribe to URL " + url + ": "
+ e.getMessage()).build();
}
return Response.ok(Status.OK).build();
}

View File

@@ -1,14 +1,11 @@
package com.commafeed.frontend.rest.resources;
import java.util.UUID;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import com.commafeed.backend.StartupBean;
@@ -120,10 +117,10 @@ public class UserREST extends AbstractResourceREST {
byte[] password = encryptionService.getEncryptedPassword(
request.getPassword(), user.getSalt());
user.setPassword(password);
user.setApiKey(generateKey(user));
user.setApiKey(userService.generateApiKey(user));
}
if (request.isNewApiKey()) {
user.setApiKey(generateKey(user));
user.setApiKey(userService.generateApiKey(user));
}
userDAO.update(user);
return Response.ok().build();
@@ -140,10 +137,4 @@ public class UserREST extends AbstractResourceREST {
userService.unregister(getUser());
return Response.ok().build();
}
private String generateKey(User user) {
byte[] key = encryptionService.getEncryptedPassword(UUID.randomUUID()
.toString(), user.getSalt());
return DigestUtils.sha1Hex(key);
}
}