+++ /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 %]
<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/user.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/patron/app.js"></script>
+<!-- required for credentials verify API -->
+<script src="[% ctx.media_prefix %]/js/dojo/opensrf/md5.js"></script>
+
<!-- load on demand? -->
<script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/patron/checkout.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/patron/items_out.js"></script>
--- /dev/null
+<div class="container">
+ <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 -->
</li>
<li class="divider"></li>
<li>
- <a href="./circ/patron/creds/index" target="_self">
+ <a href="./circ/patron/credentials" target="_self">
<span class="glyphicon glyphicon-ok"></span>
<span>[% l('Verify Credentials') %]</span>
</a>
resolve : resolver
});
+ $routeProvider.when('/circ/patron/credentials', {
+ templateUrl: './circ/patron/t_credentials',
+ controller: 'PatronVerifyCredentialsCtrl',
+ resolve : resolver
+ });
$routeProvider.when('/circ/patron/:id/checkout', {
templateUrl: './circ/patron/t_checkout',
$scope.initTab('edit', $routeParams.id);
}])
+/**
+ * Credentials tester
+ */
+.controller('PatronVerifyCredentialsCtrl',
+ ['$scope','$location','egCore',
+function($scope, $location , egCore) {
+ $scope.verified = null;
+ $scope.focusMe = true;
+
+ // 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;
+ 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)) {
+ $location.path('/circ/patron/' + 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();
+ }
+}])
+
+
+++ /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();
- }
-}])
-