mirror of
https://github.com/mempool/mempool.git
synced 2025-02-22 14:22:44 +01:00
Fix faucet 403 handling
This commit is contained in:
parent
72f4d811c1
commit
d9197e28be
2 changed files with 18 additions and 16 deletions
|
@ -28,7 +28,7 @@
|
|||
<div class="alert alert-mempool d-block text-center">
|
||||
<a [routerLink]="['/tx/' | relativeUrl, txid]">{{ txid }}</a>
|
||||
</div>
|
||||
} @else if (loading || !status) {
|
||||
} @else if (loading) {
|
||||
<p>Waiting for faucet...</p>
|
||||
<div class="spinner-border text-light"></div>
|
||||
} @else {
|
||||
|
@ -49,8 +49,8 @@
|
|||
</div>
|
||||
<div class="text-danger text-left" *ngIf="invalidAmount">
|
||||
<div *ngIf="amount?.errors?.['required']">Amount is required</div>
|
||||
<div *ngIf="status.user_requests && amount?.errors?.['min']">Minimum is {{ amount?.errors?.['min'].min }}</div>
|
||||
<div *ngIf="status.user_requests && amount?.errors?.['max']">Maximum is {{ amount?.errors?.['max'].max }}</div>
|
||||
<div *ngIf="status?.user_requests && amount?.errors?.['min']">Minimum is {{ amount?.errors?.['min'].min }}</div>
|
||||
<div *ngIf="status?.user_requests && amount?.errors?.['max']">Maximum is {{ amount?.errors?.['max'].max }}</div>
|
||||
</div>
|
||||
<div class="input-group input-group-lg mb-2">
|
||||
<div class="input-group-prepend">
|
||||
|
|
|
@ -43,20 +43,22 @@ export class FaucetComponent implements OnInit, OnDestroy {
|
|||
|
||||
ngOnInit(): void {
|
||||
this.user = this.storageService.getAuth()?.user ?? null;
|
||||
console.log(this.user);
|
||||
this.initForm(5000, 500000);
|
||||
if (this.user) {
|
||||
this.servicesApiService.getFaucetStatus$().subscribe(status => {
|
||||
this.status = status;
|
||||
this.initForm(this.status.min, this.status.user_max);
|
||||
})
|
||||
} else {
|
||||
this.status = {
|
||||
access: false,
|
||||
min: 5000,
|
||||
user_max: 500000,
|
||||
user_requests: 1,
|
||||
try {
|
||||
this.servicesApiService.getFaucetStatus$().subscribe(status => {
|
||||
this.status = status;
|
||||
this.initForm(this.status.min, this.status.user_max);
|
||||
})
|
||||
} catch (e) {
|
||||
if (e?.status !== 403) {
|
||||
this.error = 'faucet_not_available';
|
||||
}
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
this.initForm(5000, 500000);
|
||||
} else {
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
this.websocketService.want(['blocks', 'mempool-blocks']);
|
||||
|
@ -81,7 +83,7 @@ export class FaucetComponent implements OnInit, OnDestroy {
|
|||
'address': ['', [Validators.required, Validators.pattern(getRegex('address', 'testnet4'))]],
|
||||
'satoshis': ['', [Validators.required, Validators.min(min), Validators.max(max)]]
|
||||
}, { validators: (formGroup): ValidationErrors | null => {
|
||||
if (!this.status?.user_requests) {
|
||||
if (this.status && !this.status?.user_requests) {
|
||||
return { customError: 'You have used the faucet too many times already! Come back later.'}
|
||||
}
|
||||
return null;
|
||||
|
|
Loading…
Add table
Reference in a new issue