1 import {Component, Input, OnInit, AfterViewInit, ViewChild} from '@angular/core';
2 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
3 import {from, empty, range} from 'rxjs';
4 import {concatMap, tap, takeLast} from 'rxjs/operators';
5 import {NgbNav, NgbNavChangeEvent} from '@ng-bootstrap/ng-bootstrap';
6 import {IdlObject} from '@eg/core/idl.service';
7 import {EventService} from '@eg/core/event.service';
8 import {OrgService} from '@eg/core/org.service';
9 import {NetService} from '@eg/core/net.service';
10 import {PcrudService, PcrudContext} from '@eg/core/pcrud.service';
11 import {AuthService} from '@eg/core/auth.service';
12 import {PatronService} from '@eg/staff/share/patron/patron.service';
13 import {PatronContextService} from './patron.service';
16 templateUrl: 'test-password.component.html',
17 selector: 'eg-patron-test-password'
19 export class TestPatronPasswordComponent implements OnInit, AfterViewInit {
21 @Input() patronId: number;
30 private router: Router,
31 private evt: EventService,
32 private net: NetService,
33 private auth: AuthService,
34 public patronService: PatronService
40 this.patronService.getById(this.patronId,
41 {flesh: 1, flesh_fields: {au: ['card']}})
44 this.username = p.usrname();
45 this.barcode = p.card().barcode();
51 let domId = 'password-input';
52 if (!this.patronId) { domId = 'username-input'; }
53 const node = document.getElementById(domId) as HTMLInputElement;
54 if (node) { node.focus(); }
59 this.notFound = false;
63 'open-ils.actor.user.retrieve_id_by_barcode_or_username',
64 this.auth.token(), this.barcode, this.username
66 if (this.evt.parse(resp)) {
69 this.router.navigate(['/staff/circ/patron/', resp, 'checkout']);
75 if (!this.username && !this.barcode) { return; }
77 this.net.request('open-ils.actor',
78 'open-ils.actor.verify_user_password', this.auth.token(),
79 this.barcode, this.username, null, this.password)
82 const evt = this.evt.parse(resp);
89 } else if (Number(resp) === 1) {
92 this.verified = false;