Skip to content

Commit

Permalink
CSCEXAM-1404 User agreement prompt for all user roles
Browse files Browse the repository at this point in the history
  • Loading branch information
lupari committed Feb 4, 2025
1 parent 17bfdb3 commit a3689ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
18 changes: 9 additions & 9 deletions app/controllers/admin/SettingsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ public Result provideMaturityInstructions(String ref, String lang) {

@Restrict({ @Group("ADMIN") })
public Result updateUserAgreement(Http.Request request) {
DynamicForm df = formFactory.form().bindFromRequest(request);
String eula = df.get("value");
JsonNode body = request.body().asJson();
String eula = body.get("value").asText();
GeneralSettings gs = getOrCreateSettings("eula", eula, null);

// Since the EULA has changed, force users to accept it again.
String updStatement = "update app_user set user_agreement_accepted = :hasNot";
Update<User> update = DB.createUpdate(User.class, updStatement);
update.set("hasNot", false);
update.execute();

if (!body.get("majorUpdate").asBoolean()) {
// Since the EULA has changed, force users to accept it again.
String updStatement = "update app_user set user_agreement_accepted = :hasNot";
Update<User> update = DB.createUpdate(User.class, updStatement);
update.set("hasNot", false);
update.execute();
}
return ok(Json.toJson(gs));
}

Expand Down
8 changes: 7 additions & 1 deletion ui/src/app/administrative/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@
</div>
</div>
<div class="row mt-2">
<div class="col-12">
<div class="col-1">
<button (click)="updateAgreement()" class="btn btn-success">
{{ 'i18n_button_save' | translate }}
</button>
</div>
<div class="col form-check mt-2">
<label class="form-check-label ms-2" for="exclude-update">{{
'i18n_minor_agreement_update' | translate
}}</label>
<input id="exclude-update" class="form-check-input" type="checkbox" [(ngModel)]="majorAgreementUpdate" />
</div>
</div>

<div class="row mt-2 align-items-end">
Expand Down
6 changes: 5 additions & 1 deletion ui/src/app/administrative/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { SettingsService } from './settings.service';
export class SettingsComponent implements OnInit {
config!: AppConfig;
attributes: string[] = [];
majorAgreementUpdate = false;

constructor(
private Settings: SettingsService,
Expand All @@ -45,7 +46,10 @@ export class SettingsComponent implements OnInit {
}

updateAgreement = () =>
this.Settings.updateAgreement$(this.config).subscribe({ next: this.onSuccess, error: this.onError });
this.Settings.updateAgreement$(this.config, this.majorAgreementUpdate).subscribe({
next: this.onSuccess,
error: this.onError,
});

updateDeadline = () =>
this.Settings.updateDeadline$(this.config).subscribe({ next: this.onSuccess, error: this.onError });
Expand Down

0 comments on commit a3689ec

Please sign in to comment.