--- /dev/null
+[%
+ WRAPPER "staff/base.tt2";
+ ctx.page_title = l("Verify Patron Credentials");
+ ctx.page_app = "egPatronCredsApp";
+%]
+
+[% BLOCK APP_JS %]
+<!-- needed for password mangling -->
+<script src="[% ctx.media_prefix %]/js/dojo/opensrf/md5.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/patron/creds/app.js"></script>
+[% END %]
+
+
+<div class="container" ng-controller="PatronVerifyCredentialsCtrl">
+ <div class="row">
+ <div class="col-md-6">
+ <fieldset>
+ <legend>[% l('Verify Credentials') %]</legend>
+ <form ng-submit="verify()"
+ name="verify-creds-form" class="form-horizontal" role="form">
+
+ <div class="form-group">
+ <label class="col-md-4 control-label"
+ for="verify-username">[% l('Username') %]</label>
+ <div class="col-md-8">
+ <input type="text" id="verify-username" class="form-control"
+ focus-me="focusMe"
+ placeholder="[% l('Username') %]" ng-model="username"/>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-md-4 control-label"
+ for="verify-barcode">[% l('Barcode') %]</label>
+ <div class="col-md-8">
+ <input type="text" id="verify-barcode" class="form-control"
+ placeholder="[% l('Barcode') %]" ng-model="barcode"/>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-md-4 control-label"
+ for="verify-password">[% l('Password') %]</label>
+ <div class="col-md-8">
+ <input type="password" id="verify-password" class="form-control"
+ placeholder="[% l('Password') %]" ng-model="password"/>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <div class="col-md-offset-4 col-md-2">
+ <button type="submit" class="btn btn-default">[% l('Verify') %]</button>
+ </div>
+ <div class="col-md-2">
+ <button class="btn btn-default" ng-click="load($event)">[% l('Retrieve') %]</button>
+ </div>
+ </div>
+
+ <div class="form-group" ng-cloak>
+ <div class="col-md-offset-4 col-md-8">
+ <div class="alert alert-success" ng-show="verified">
+ [% l('Succes testing credentials') %]
+ </div>
+ <div class="alert alert-danger" ng-show="verified === false">
+ [% l('Failure testing credentials') %]
+ </div>
+ <div class="alert alert-danger" ng-show="notFound">
+ [% l('No user found with the requested username / barcode') %]
+ </div>
+ </div>
+ </div>
+
+ </form>
+ </fieldset>
+ <div><!-- col -->
+ </div><!-- row -->
+</div><!-- container -->
+[% END %]
<li><a href='./' title="[% l('Home') %]" target="_self"
class="glyphicon glyphicon-home"></a><li>
+ <!-- search -->
+ <li class="dropdown">
+ <a href="javascript:;" class="dropdown-toggle"
+ data-toggle="dropdown">[% l('Search') %]
+ <b class="caret"></b>
+ </a>
+ <ul class="dropdown-menu">
+ <li>
+ <a href="./circ/patron/search" target="_self"
+ eg-accesskey="[% l('alt+s') %]"
+ eg-accesskey-desc="[% l('Patron search by name, address, etc.') %]">
+ <span class="glyphicon glyphicon-search"></span>
+ <span eg-accesskey-label>[% l('Search for Patrons') %]</span>
+ </a>
+ </li>
+ </ul>
+ </li>
+
+
<!-- circulation -->
<li class="dropdown">
<a href="javascript:;" class="dropdown-toggle"
</a>
</li>
<li>
- <a href="./circ/patron/search" target="_self"
- eg-accesskey="[% l('alt+s') %]"
- eg-accesskey-desc="[% l('Patron search by name, address, etc.') %]">
- <span class="glyphicon glyphicon-search"></span>
- <span eg-accesskey-label>[% l('Patron Search') %]</span>
- </a>
- </li>
- <li>
<a href="./circ/checkin/index" target="_self">
<span class="glyphicon glyphicon-import"></span>
[% l('Check In') %]
</a>
</li>
- <!-- sample sub-menu
<li class="divider"></li>
- <li class="dropdown-header">Sub Menu Test</li>
- <li><a href="javascript:;">Test Item</a></li>
- -->
+ <li>
+ <a href="./circ/patron/creds/index" target="_self">
+ <span class="glyphicon glyphicon-ok"></span>
+ <span>[% l('Verify Credentials') %]</span>
+ </a>
+ </li>
</ul>
</li>
--- /dev/null
+/**
+ * Patron Credentials App
+ */
+
+angular.module('egPatronCredsApp', ['ngRoute', 'egCoreMod', 'egUiMod'])
+
+.config(function($locationProvider, $compileProvider) {
+ $locationProvider.html5Mode(true);
+ $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); // grid export
+})
+
+
+/**
+ * Manages edit
+ */
+.controller('PatronVerifyCredentialsCtrl',
+ ['$scope','$window','egCore',
+function($scope, $window , egCore) {
+ $scope.verified = null;
+ $scope.focusMe = true;
+
+ // standalone controller w/ no resolver; load startup manually
+ egCore.startup.go();
+
+ // verify login credentials
+ $scope.verify = function() {
+ $scope.verified = null;
+ $scope.notFound = false;
+
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.verify_user_password',
+ egCore.auth.token(),
+ $scope.barcode,
+ $scope.username,
+ hex_md5($scope.password || '')
+ ).then(function(resp) {
+ $scope.focusMe = true;
+ console.debug('verify replied ' + resp);
+ if (evt = egCore.evt.parse(resp)) {
+ alert(evt);
+ } else if (resp == 1) {
+ $scope.verified = true;
+ } else {
+ $scope.verified = false;
+ }
+ });
+ }
+
+ // load the main patron UI for the provided username or barcode
+ $scope.load = function($event) {
+ $scope.notFound = false;
+ $scope.verified = null;
+
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.user.retrieve_id_by_barcode_or_username',
+ egCore.auth.token(),
+ $scope.barcode,
+ $scope.username
+ ).then(function(resp) {
+ if (Number(resp)) {
+ $window.location.href =
+ $window.location.href
+ .replace(/creds.*/,resp + '/checkout');
+ return;
+ }
+
+ // something went wrong...
+ $scope.focusMe = true;
+ if (evt = egCore.evt.parse(resp)) {
+ if (evt.textcode == 'ACTOR_USR_NOT_FOUND') {
+ $scope.notFound = true;
+ return;
+ }
+ return alert(evt);
+ } else {
+ alert(resp);
+ }
+ });
+
+ // load() button sits within the verify form.
+ // avoid submitting the verify() form action on load()
+ $event.preventDefault();
+ }
+}])
+