demo account creation is now skipped by default

This commit is contained in:
Athou
2014-11-23 13:27:34 +01:00
parent 4684e43f42
commit 6419d29489
4 changed files with 13 additions and 3 deletions

View File

@@ -7,6 +7,9 @@ app:
# wether to allow user registrations # wether to allow user registrations
allowRegistrations: false allowRegistrations: false
# create a demo account the first time the app starts
createDemoAccount: false
# put your google analytics tracking code here # put your google analytics tracking code here
googleAnalyticsTrackingCode: googleAnalyticsTrackingCode:

View File

@@ -69,6 +69,8 @@ public class CommaFeedConfiguration extends Configuration {
@NotNull @NotNull
private boolean allowRegistrations; private boolean allowRegistrations;
private boolean createDemoAccount;
private String googleAnalyticsTrackingCode; private String googleAnalyticsTrackingCode;
@NotNull @NotNull

View File

@@ -26,6 +26,7 @@ import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.internal.SessionFactoryImpl; import org.hibernate.internal.SessionFactoryImpl;
import com.commafeed.CommaFeedApplication; import com.commafeed.CommaFeedApplication;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.dao.UnitOfWork; import com.commafeed.backend.dao.UnitOfWork;
import com.commafeed.backend.dao.UserDAO; import com.commafeed.backend.dao.UserDAO;
import com.commafeed.backend.model.UserRole.Role; import com.commafeed.backend.model.UserRole.Role;
@@ -38,6 +39,7 @@ public class StartupService implements Managed {
private final SessionFactory sessionFactory; private final SessionFactory sessionFactory;
private final UserDAO userDAO; private final UserDAO userDAO;
private final UserService userService; private final UserService userService;
private final CommaFeedConfiguration config;
@Override @Override
public void start() throws Exception { public void start() throws Exception {
@@ -95,7 +97,9 @@ public class StartupService implements Managed {
try { try {
userService.register(CommaFeedApplication.USERNAME_ADMIN, "admin", "admin@commafeed.com", Arrays.asList(Role.ADMIN, Role.USER), userService.register(CommaFeedApplication.USERNAME_ADMIN, "admin", "admin@commafeed.com", Arrays.asList(Role.ADMIN, Role.USER),
true); true);
if (config.getApplicationSettings().isCreateDemoAccount()) {
userService.register(CommaFeedApplication.USERNAME_DEMO, "demo", "demo@commafeed.com", Arrays.asList(Role.USER), true); userService.register(CommaFeedApplication.USERNAME_DEMO, "demo", "demo@commafeed.com", Arrays.asList(Role.USER), true);
}
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }

View File

@@ -249,7 +249,7 @@ public class UserREST {
sessionHelper.setLoggedInUser(user.get()); sessionHelper.setLoggedInUser(user.get());
return Response.ok().build(); return Response.ok().build();
} else { } 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(); return Response.ok().build();
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), 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();
} }
} }