mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
welcome page
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -14,5 +14,6 @@ public class ServerInfo implements Serializable {
|
||||
private String announcement;
|
||||
private String version;
|
||||
private String gitCommit;
|
||||
private boolean allowRegistrations;
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user