Commit 919848cf by Anton Sudak

Save user's password when creating account via backend if there is any

parent 4dac3ac5
......@@ -140,7 +140,10 @@ public class PartyController extends Controller {
partyCreateViewProvider.get().setForm(form).render()));
}
Party party = partyService.save(form.get());
Party unsavedParty = form.get();
getUserPassword(unsavedParty).field("password").getValue().ifPresent(unsavedParty::setCredentials);
Party party = partyService.save(unsavedParty);
partyEvents.onCreate(form, party);
......@@ -252,13 +255,7 @@ public class PartyController extends Controller {
playAuthApi.requirePermission(PartyPermission.EDIT_PASSWORD, party);
final Form<? extends RepeatedPassword> form;
if (RepeatedPassword.class.isAssignableFrom(partyService.getPartyClass())) {
form = (Form) partyService.getPartyForm(PartyConstrains.OnPasswordChange.class)
.bindFromRequest("password", "repeatPassword");
} else {
form = smartFormFactory.form(PasswordChange.class).bindFromRequest();
}
Form<? extends RepeatedPassword> form = getUserPassword(party);
if (form.hasErrors()) {
return badRequest(SecureForm.signForms(
......@@ -400,4 +397,13 @@ public class PartyController extends Controller {
return ok(partyDatatableService.getDatatable(request()));
}
private Form<? extends RepeatedPassword> getUserPassword(Party party) {
if (RepeatedPassword.class.isAssignableFrom(partyService.getPartyClass())) {
return (Form) partyService.getPartyForm(PartyConstrains.OnPasswordChange.class)
.bindFromRequest("password", "repeatPassword");
} else {
return smartFormFactory.form(PasswordChange.class).bindFromRequest();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment