Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

issue#144 throwing proper error message for badge assertion in issuer…

… api
  • Loading branch information...
commit 4237178b51c0eeece09bdcdc4ffcaf2bab09714c 1 parent e1998fd
@pradeepmurugesan pradeepmurugesan authored
View
8 fakeissuer/issuer.js
@@ -52,6 +52,14 @@ app.get('/hashed.json', function (request, response) {
});
});
+app.get('/invalid.json', function (request, response) {
+ return response.send({
+ recipient: request.query.email||'brian@mozillafoundation.org',
+ evidence: '/whatever.html',
+ expires: '2040-08-13',
+ issued_on: '2011-08-23'
+ });
+});
View
7 fakeissuer/static/index.html
@@ -13,9 +13,11 @@
<label>Email: <input id='email'></label>
<button id='unhashed'>Unhashed</button>
<button id='hashed'>Hashed</button>
+ <button id='invalid'>Invalid</button>
<script>
var unhashed = document.getElementById('unhashed');
var hashed = document.getElementById('hashed');
+ var invalid = document.getElementById('invalid');
function getEmail() {
return document.getElementById('email').value;
}
@@ -27,6 +29,11 @@
hashed.addEventListener('click', function(){
OpenBadges.issue(['http://localhost:8889/hashed.json?email=' + encodeURIComponent(getEmail())]);
},false)
+
+ // added to test whether proper error message is thrown for invalid assertion
+ invalid.addEventListener('click', function(){
+ OpenBadges.issue(['http://localhost:8889/invalid.json?email=' + encodeURIComponent(getEmail())]);
+ },false)
</script>
</body>
View
9 static/js/issuer-frame.js
@@ -442,13 +442,16 @@ function issue(assertions, cb) {
});
}
},
- error: function() {
+ error: function(xhr) {
assertions.pop();
+ var templateArgs = {
+ error : jQuery.parseJSON(xhr.responseText)
+ };
errors.push({
url: url,
- reason: 'INACCESSIBLE'
+ reason: templateArgs.error.message
});
- showError("#inaccessible-template", {});
+ showError("#inaccessible-template", templateArgs);
processNext();
}
});
View
2  views/issuer-frame.hogan.js
@@ -74,7 +74,7 @@
<div id="inaccessible-template">
<div class="alert alert-error">
<a class="close">×</a>
- An assertion URL could not be retrieved.
+ <em>[[ error.message ]]</em>
</div>
</div>
<div id="login-error-template">
Please sign in to comment.
Something went wrong with that request. Please try again.