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