Add duplicated user error on create

pull/10/head
Florian Hartwich 2017-09-15 21:02:43 +02:00
parent 17b31df9a6
commit 5a7f002bdd
3 changed files with 24 additions and 7 deletions

View File

@ -39,7 +39,6 @@ const createAllSignatures = () => {
+ ': finished successful - UPDATE SIGNATURES'); + ': finished successful - UPDATE SIGNATURES');
}) })
}); });
}; };
const createBackup = () => { const createBackup = () => {
@ -55,11 +54,10 @@ const createBackup = () => {
}) })
}; };
// Execute daily @ 02:30 AM // Execute daily @ 02:30 AM
const cronJobSignature = cron.job('00 30 02 * * *', createAllSignatures); const cronJobSignature = cron.job('00 30 02 * * *', createAllSignatures);
// Execute every on Mon, Thu and Sat @ 04:00 AM // Execute on Mon, Thu and Sat @ 04:00 AM
const cronJobBackup = cron.job('00 00 04 * * mon,thu,sat', createBackup); const cronJobBackup = cron.job('00 00 04 * * mon,thu,sat', createBackup);
module.exports = { module.exports = {

View File

@ -57,10 +57,15 @@
Bestätigen Bestätigen
</button> </button>
<span *ngIf="showErrorLabel"
class="center-block label label-danger" style="font-size: medium; padding: 2px; margin-top: 2px">
{{error}}
</span>
<span *ngIf="showSuccessLabel" <span *ngIf="showSuccessLabel"
class="label label-success label-small" class="label label-success label-small"
style="margin-left: inherit"> style="margin-left: inherit">
Erfolgreich gespeichert Erfolgreich gespeichert
</span> </span>
</form> </form>

View File

@ -28,6 +28,10 @@ export class EditUserComponent {
ranksDisplay = 'none'; ranksDisplay = 'none';
showErrorLabel = false;
error: string;
constructor(private router: Router, constructor(private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private userService: UserService, private userService: UserService,
@ -98,9 +102,19 @@ export class EditUserComponent {
} else { } else {
this.userService.submitUser(updateObject) this.userService.submitUser(updateObject)
.subscribe(user => { .subscribe(user => {
this.router.navigate(['..'], {relativeTo: this.route}); this.router.navigate(['..'], {relativeTo: this.route});
return true; return true;
}) },
error => {
// duplicated user error message
if (error._body.indexOf('duplicate') >= 0) {
this.error = "Benutzername existiert bereits";
this.showErrorLabel = true;
setTimeout(() => {
this.showErrorLabel = false;
}, 5000);
}
})
} }
} }