forked from Archives/Athou_commafeed
demo account creation is now skipped by default
This commit is contained in:
@@ -69,6 +69,8 @@ public class CommaFeedConfiguration extends Configuration {
|
||||
@NotNull
|
||||
private boolean allowRegistrations;
|
||||
|
||||
private boolean createDemoAccount;
|
||||
|
||||
private String googleAnalyticsTrackingCode;
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.internal.SessionFactoryImpl;
|
||||
|
||||
import com.commafeed.CommaFeedApplication;
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.dao.UnitOfWork;
|
||||
import com.commafeed.backend.dao.UserDAO;
|
||||
import com.commafeed.backend.model.UserRole.Role;
|
||||
@@ -38,6 +39,7 @@ public class StartupService implements Managed {
|
||||
private final SessionFactory sessionFactory;
|
||||
private final UserDAO userDAO;
|
||||
private final UserService userService;
|
||||
private final CommaFeedConfiguration config;
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
@@ -95,7 +97,9 @@ public class StartupService implements Managed {
|
||||
try {
|
||||
userService.register(CommaFeedApplication.USERNAME_ADMIN, "admin", "admin@commafeed.com", Arrays.asList(Role.ADMIN, Role.USER),
|
||||
true);
|
||||
userService.register(CommaFeedApplication.USERNAME_DEMO, "demo", "demo@commafeed.com", Arrays.asList(Role.USER), true);
|
||||
if (config.getApplicationSettings().isCreateDemoAccount()) {
|
||||
userService.register(CommaFeedApplication.USERNAME_DEMO, "demo", "demo@commafeed.com", Arrays.asList(Role.USER), true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ public class UserREST {
|
||||
sessionHelper.setLoggedInUser(user.get());
|
||||
return Response.ok().build();
|
||||
} else {
|
||||
return Response.status(Response.Status.UNAUTHORIZED).entity("wrong username or password").build();
|
||||
return Response.status(Response.Status.UNAUTHORIZED).entity("wrong username or password").type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +270,8 @@ public class UserREST {
|
||||
return Response.ok().build();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Response.status(Status.INTERNAL_SERVER_ERROR).entity("could not send email: " + e.getMessage()).build();
|
||||
return Response.status(Status.INTERNAL_SERVER_ERROR).entity("could not send email: " + e.getMessage())
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user