Permalink
Browse files

Make password and username field in basic authentication dialog optio…

…nal (issue #78)
  • Loading branch information...
1 parent c1c3a9a commit 9ddc9f5cc1ca353ed796b9b00a77e880cf3ba855 @chao committed Jun 1, 2012
Showing with 33 additions and 6 deletions.
  1. +22 −4 content/js/restclient.main.js
  2. +11 −2 content/restclient.html
@@ -594,19 +594,37 @@ restclient.main = {
});
return false;
},
- addBasicAuthorization: function () {
+ addBasicAuthorization: function (ignore, remember) {
var username = $("#modal-basic-authorization [name='username']"),
- password = $("#modal-basic-authorization [name='password']");
- if (username.val() == '') {
+ password = $("#modal-basic-authorization [name='password']"),
+ btnOkay = $("#modal-basic-authorization .btnOkay"),
+ btnGroup = $("#modal-basic-authorization .btn-group");
+
+ if(remember === true)
+ restclient.setPref('ignoreBasicAuthCheck', 'yes');
+
+ if(restclient.getPref('ignoreBasicAuthCheck', 'no') === 'yes')
+ ignore = true;
+ if(typeof ignore === 'undefined')
+ ignore = false;
+
+ if (username.val() == '' && !ignore) {
username.next().text('Please input the username for authorization').show();
username.focus();
+ btnOkay.hide();
+ btnGroup.show();
return false;
}
- if (password.val() == '') {
+ if (password.val() == '' && !ignore) {
password.next().text('Please input the password for authorization').show();
password.focus();
+ btnOkay.hide();
+ btnGroup.show();
return false;
}
+
+ btnOkay.show();
+ btnGroup.hide();
var strValue = username.val() + ":" + password.val(),
strBase64 = btoa(strValue).replace(/.{76}(?=.)/g,'$&\n');
View
@@ -204,8 +204,17 @@ <h3>Basic Authorization</h3>
<div style="float:left;margin-top:8px; ">
<input type="checkbox" name="remember" style="margin-right: 6px;"><span style="margin-top: 10px;">Remember me</span>
</div>
- <input class="btn btn-inverse" type="button" value="Okay" onclick="restclient.main.addBasicAuthorization();">
- <input class="btn btnClose" type="button" value="Cancel">
+ <input class="btn btnClose" type="button" value="Cancel" style="float:right; padding: 5px 10px;">
+ <input class="btn btnOkay btn-inverse" type="button" value="Okay" onclick="restclient.main.addBasicAuthorization();" style="float:right; padding: 5px 10px; margin: 0 6px;">
+ <div class="btn-group dropup hide" style="float:right; margin: 0 6px; text-align:left">
+ <button class="btn btn-inverse btnAuthorize" style="padding: 4px 10px;" onclick="restclient.main.addBasicAuthorization(true);">Ignore the warning</button>
+ <button class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" style="padding: 4px 6px;"><span class="caret"></span></button>
+ <ul class="dropdown-menu pull-right">
+ <li><a onclick="restclient.main.addBasicAuthorization(true, true);">Ignore the warning and remember my decision</a></li>
+ </ul>
+ </div>
+
+
</div>
</div>
<div class="modal fade hide" id="modal-custom-header">

0 comments on commit 9ddc9f5

Please sign in to comment.