welcome page

This commit is contained in:
Athou
2014-08-09 16:07:24 +02:00
parent 33b683d037
commit bbf04c4687
10 changed files with 139 additions and 13 deletions

View File

@@ -33,7 +33,7 @@ public class UserService {
public Optional<User> login(String name, String password) {
if (name == null || password == null) {
return null;
return Optional.absent();
}
User user = userDAO.findByName(name);

View File

@@ -14,5 +14,6 @@ public class ServerInfo implements Serializable {
private String announcement;
private String version;
private String gitCommit;
private boolean allowRegistrations;
}

View File

@@ -39,11 +39,12 @@ public class ServerREST {
@GET
@UnitOfWork
@ApiOperation(value = "Get server infos", notes = "Get server infos", response = ServerInfo.class)
public Response get(@SecurityCheck User user) {
public Response get() {
ServerInfo infos = new ServerInfo();
infos.setAnnouncement(config.getApplicationSettings().getAnnouncement());
infos.setVersion(applicationPropertiesService.getVersion());
infos.setGitCommit(applicationPropertiesService.getGitCommit());
infos.setAllowRegistrations(config.getApplicationSettings().isAllowRegistrations());
return Response.ok(infos).build();
}

View File

@@ -216,10 +216,10 @@ public class UserREST {
public Response login(@ApiParam(required = true) LoginRequest req, @Session HttpSession session) {
Optional<User> user = userService.login(req.getName(), req.getPassword());
if (user.isPresent()) {
session.setAttribute(CommaFeedApplication.SESSION_USER, user);
session.setAttribute(CommaFeedApplication.SESSION_USER, user.get());
return Response.ok().build();
} else {
return Response.status(Response.Status.UNAUTHORIZED).build();
return Response.status(Response.Status.UNAUTHORIZED).entity("wrong username or password").build();
}
}