Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #159 from pradeepmurugesan/issue-144
Browse files Browse the repository at this point in the history
issue#144 throwing proper error message for badge assertion in issuer api
  • Loading branch information
stenington committed May 10, 2012
2 parents e1998fd + 46cf0e6 commit 65e69b8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
8 changes: 8 additions & 0 deletions fakeissuer/issuer.js
Expand Up @@ -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'
});
});



Expand Down
7 changes: 7 additions & 0 deletions fakeissuer/static/index.html
Expand Up @@ -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;
}
Expand All @@ -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>
Expand Down
10 changes: 7 additions & 3 deletions static/js/issuer-frame.js
Expand Up @@ -442,13 +442,17 @@ 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: 'INACCESSIBLE',
message: templateArgs.error.message
});
showError("#inaccessible-template", {});
showError("#inaccessible-template", templateArgs);
processNext();
}
});
Expand Down
2 changes: 1 addition & 1 deletion views/issuer-frame.hogan.js
Expand Up @@ -74,7 +74,7 @@
<div id="inaccessible-template">
<div class="alert alert-error">
<a class="close">×</a>
An assertion URL could not be retrieved.
We have encountered the following problem: <em>[[ error.message ]]</em>
</div>
</div>
<div id="login-error-template">
Expand Down

0 comments on commit 65e69b8

Please sign in to comment.