Fix password issues & report list in bug tab

This commit is contained in:
F43nd1r 2017-05-29 18:25:35 +02:00
parent 1445b987a0
commit 8474f34528
7 changed files with 33 additions and 18 deletions

View file

@ -56,7 +56,7 @@ public class BackendUI extends UI {
private boolean login(String username, String password) {
try {
Authentication token = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password));
Authentication token = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username.toLowerCase(), password));
VaadinService.reinitializeSession(VaadinService.getCurrentRequest());
SecurityContextHolder.getContext().setAuthentication(token);
showMain();

View file

@ -5,10 +5,10 @@ import com.faendir.acra.mongod.model.App;
import com.faendir.acra.mongod.model.Permission;
import com.faendir.acra.security.SecurityUtils;
import com.faendir.acra.ui.view.base.NamedView;
import com.faendir.acra.ui.view.base.ReportList;
import com.faendir.acra.ui.view.tabs.BugTab;
import com.faendir.acra.ui.view.tabs.DeObfuscationTab;
import com.faendir.acra.ui.view.tabs.PropertiesTab;
import com.faendir.acra.ui.view.tabs.ReportTab;
import com.faendir.acra.ui.view.tabs.StatisticsTab;
import com.faendir.acra.util.Style;
import com.vaadin.navigator.ViewChangeListener;
@ -48,7 +48,7 @@ public class AppView extends NamedView {
String[] parameters = event.getParameters().split("/");
App app = dataManager.getApp(parameters[0]);
TabSheet tabSheet = new TabSheet(new BugTab(app.getId(), getNavigationManager(), dataManager),
new ReportList(app.getId(), getNavigationManager(), dataManager),
new ReportTab(app.getId(), getNavigationManager(), dataManager),
new StatisticsTab(app.getId(), dataManager), new DeObfuscationTab(app.getId(), dataManager));
if(SecurityUtils.hasPermission(app.getId(), Permission.Level.ADMIN)){
tabSheet.addComponent(new PropertiesTab(app, dataManager, getNavigationManager()));

View file

@ -10,18 +10,19 @@ import com.faendir.acra.util.TimeSpanRenderer;
import com.vaadin.shared.data.sort.SortDirection;
import com.vaadin.ui.renderers.ButtonRenderer;
import java.util.List;
import java.util.function.Supplier;
/**
* @author Lukas
* @since 14.05.2017
*/
public class ReportList extends MyGrid<Report> implements DataManager.ReportChangeListener {
private final String app;
private final DataManager dataManager;
private final Supplier<List<Report>> reportSupplier;
public ReportList(String app, NavigationManager navigationManager, DataManager dataManager) {
super("Reports", dataManager.getReports(app));
this.app = app;
this.dataManager = dataManager;
public ReportList(String app, NavigationManager navigationManager, DataManager dataManager, Supplier<List<Report>> reportSupplier) {
super("Reports", reportSupplier.get());
this.reportSupplier = reportSupplier;
setSizeFull();
setSelectionMode(SelectionMode.NONE);
sort(addColumn(Report::getDate, new TimeSpanRenderer(), "Date"), SortDirection.DESCENDING);
@ -39,6 +40,6 @@ public class ReportList extends MyGrid<Report> implements DataManager.ReportChan
@Override
public void onChange() {
setItems(dataManager.getReports(app));
setItems(reportSupplier.get());
}
}

View file

@ -46,7 +46,7 @@ public class BugTab extends VerticalLayout implements DataManager.ReportChangeLi
if (getComponentCount() == 2) {
removeComponent(getComponent(1));
}
e.getFirstSelectedItem().ifPresent(bug -> addComponent(new ReportList(app, navigationManager, dataManager)));
e.getFirstSelectedItem().ifPresent(bug -> addComponent(new ReportList(app, navigationManager, dataManager, bug::getReports)));
}
@Override

View file

@ -0,0 +1,15 @@
package com.faendir.acra.ui.view.tabs;
import com.faendir.acra.mongod.data.DataManager;
import com.faendir.acra.ui.NavigationManager;
import com.faendir.acra.ui.view.base.ReportList;
/**
* @author Lukas
* @since 29.05.2017
*/
public class ReportTab extends ReportList {
public ReportTab(String app, NavigationManager navigationManager, DataManager dataManager) {
super(app, navigationManager, dataManager, () -> dataManager.getReports(app));
}
}

View file

@ -46,17 +46,16 @@ public class ChangePasswordView extends NamedView {
PasswordField repeatPassword = new PasswordField("Repeat Password");
Button confirm = new Button("Confirm", e -> {
User user = userManager.getUser(SecurityUtils.getUsername());
if(userManager.checkPassword(user, oldPassword.getValue())) {
if (newPassword.getValue().equals(repeatPassword.getValue())) {
user.setPassword(newPassword.getValue());
if (newPassword.getValue().equals(repeatPassword.getValue())) {
if (userManager.changePassword(user, oldPassword.getValue(), newPassword.getValue())) {
Notification.show("Successful!");
getNavigationManager().navigateBack();
backendUI.logout();
} else {
repeatPassword.setComponentError(new UserError("Passwords do not match"));
oldPassword.setComponentError(new UserError("Incorrect password"));
}
}else {
oldPassword.setComponentError(new UserError("Incorrect password"));
} else {
repeatPassword.setComponentError(new UserError("Passwords do not match"));
}
});

View file

@ -90,7 +90,7 @@ public class UserManagerView extends NamedView {
Button create = new Button("Create");
create.addClickListener(e -> {
if (password.getValue().equals(repeatPassword.getValue())) {
userManager.createUser(name.getValue(), password.getValue());
userManager.createUser(name.getValue().toLowerCase(), password.getValue());
userGrid.setItems(userManager.getUsers());
window.close();
} else {