can now add and remove email address claims from the UI

pull/708/merge
Justin Richer 2015-03-30 17:54:16 -04:00
parent 1ad1813239
commit 6e095e3266
2 changed files with 25 additions and 3 deletions

View File

@ -214,7 +214,7 @@ var ClaimListView = Backbone.View.extend({
events:{
'click .btn-save':'savePolicy',
'click .btn-cancel':'cancel',
'click .btn-share':'addClaim'
'click #add-email':'addClaim'
},
cancel:function(e) {
@ -252,6 +252,28 @@ var ClaimListView = Backbone.View.extend({
});
},
addClaim:function(e) {
e.preventDefault();
// post to the webfinger helper and get the response back
var _self = this;
var email = $('#email', this.el).val();
var base = $('base').attr('href');
$.getJSON(base + '/api/emailsearch?' + $.param({'identifier': email}), function(data) {
var claim = new ClaimModel(data);
_self.model.add(claim, {'trigger': false});
_self.render();
}).error(function(jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
});
},
togglePlaceholder:function() {
if (this.model.length > 0) {
$('#required-claim-table', this.el).show();

View File

@ -73,7 +73,7 @@ public class UserClaimSearchHelper {
if (localUser != null) {
Map<String, Object> entity = new HashMap<>();
entity.put("issuers", ImmutableSet.of(config.getIssuer()));
entity.put("issuer", ImmutableSet.of(config.getIssuer()));
entity.put("name", "email");
entity.put("value", localUser.getEmail());
@ -88,7 +88,7 @@ public class UserClaimSearchHelper {
if (resp != null && resp.getIssuer() != null) {
// we found an issuer, return that
Map<String, Object> entity = new HashMap<>();
entity.put("issuers", ImmutableSet.of(resp.getIssuer()));
entity.put("issuer", ImmutableSet.of(resp.getIssuer()));
entity.put("name", "email");
entity.put("value", email);