1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2024-11-13 07:39:02 +01:00

Added Delete Account feature (no dev backend support yet) - fix

This commit is contained in:
Dario Chiappetta 2015-04-14 10:44:23 +02:00
parent 00ab234ed8
commit e2781071d0
10 changed files with 208 additions and 33 deletions

View File

@ -2043,6 +2043,27 @@ span.count {
display: block; }
#extraFeaturesPanel .extraFeatureContent .changePassphraseForm input {
display: block; }
#extraFeaturesPanel .extraFeatureContent .deleteAccountForm {
margin-top: 1em; }
#extraFeaturesPanel .extraFeatureContent .deleteAccountForm label {
display: block; }
#extraFeaturesPanel .extraFeatureContent .deleteAccountForm input {
display: inline-block;
margin-right: 1em;
margin-bottom: 1em; }
#extraFeaturesPanel .extraFeatureContent .deleteAccountForm .confirmCheckbox {
display: inline-block; }
#extraFeaturesPanel .extraFeatureContent form input.valid + .invalidMsg, #extraFeaturesPanel .extraFeatureContent form input.empty + .invalidMsg, #extraFeaturesPanel .extraFeatureContent form input:focus + .invalidMsg, #extraFeaturesPanel .extraFeatureContent form input.invalid:focus + .invalidMsg {
visibility: hidden; }
#extraFeaturesPanel .extraFeatureContent form input:focus {
border: 2px solid #ff9900; }
#extraFeaturesPanel .extraFeatureContent form input.valid:focus {
border: 2px solid #1863a1; }
#extraFeaturesPanel .extraFeatureContent form input.invalid + .invalidMsg {
visibility: visible; }
#extraFeaturesPanel .extraFeatureContent form .invalidMsg::before {
font-family: serif;
content: "\26A0 \0000a0"; }
.mainPage.narrow #extraFeaturesPanel .extraFeatureContent header {
display: block;

File diff suppressed because one or more lines are too long

View File

@ -243,6 +243,44 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
return deferredResult;
},
// TODO: test (taken straight from /beta)
'deleteAccount': function() {
console.log("deleting account from user");
var deferredResult;
deferredResult = new MochiKit.Async.Deferred("User.deleteAccount", {trace: true});
deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteUser');
deferredResult.addCallback(MochiKit.Base.method(this, 'resetAllLocalData'));
deferredResult.callback();
return deferredResult;
},
// TODO: check (I have half of an idea what i'm doing)
'resetAllLocalData': function() {
console.log("resetting all local data...");
var deferredResult;
deferredResult = new MochiKit.Async.Deferred("User.resetAllLocalData", {trace: true});
deferredResult.addCallback(MochiKit.Base.method(this, 'deleteAllCleanTextData'));
deferredResult.addCallback(MochiKit.Base.method(this, function() {
this.resetConnection();
this.setUsername("");
this._getPassphraseFunction = function() { return ""; };
this._serverData = null;
}));
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------

View File

@ -33,10 +33,11 @@ Clipperz.PM.UI.Components.ExtraFeatures.PassphraseClass = React.createClass({
getInitialState: function() {
return {
// 'username': '',
// 'old-passphrase': '',
'username': '',
'old-passphrase': '',
'new-passphrase': '',
'confirm-new-passphrase': ''
'confirm-new-passphrase': '',
'error': ''
};
},
@ -44,8 +45,8 @@ Clipperz.PM.UI.Components.ExtraFeatures.PassphraseClass = React.createClass({
shouldEnableChangePassphraseButton: function() {
return (
// this.state['username'] &&
// this.state['old-passphrase'] &&
this.state['username'] &&
this.state['old-passphrase'] &&
this.state['new-passphrase'] &&
this.state['confirm-new-passphrase'] &&
(this.state['new-passphrase'] == this.state['confirm-new-passphrase'])
@ -54,8 +55,8 @@ Clipperz.PM.UI.Components.ExtraFeatures.PassphraseClass = React.createClass({
handleFormChange: function() {
this.setState({
// 'username': this.refs['username'].getDOMNode().value,
// 'old-passphrase': this.refs['old-passphrase'].getDOMNode().value,
'username': this.refs['username'].getDOMNode().value,
'old-passphrase': this.refs['old-passphrase'].getDOMNode().value,
'new-passphrase': this.refs['new-passphrase'].getDOMNode().value,
'confirm-new-passphrase': this.refs['confirm-new-passphrase'].getDOMNode().value
});
@ -63,30 +64,58 @@ Clipperz.PM.UI.Components.ExtraFeatures.PassphraseClass = React.createClass({
handleChangePassphrase: function(event) {
event.preventDefault();
MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'changePassphrase', this.refs['new-passphrase'].getDOMNode().value);
this.refs['new-passphrase'].getDOMNode().value = '';
this.refs['confirm-new-passphrase'].getDOMNode().value = '';
if (this.refs['username'].getDOMNode().value != this.props.userInfo['username']) {
this.setState({error: "Invalid username"});
return;
}
var deferredResult;
deferredResult = new Clipperz.Async.Deferred("Passphrase.handleChangePassphrase", {trace: false});
deferredResult.addCallback(this.props.userInfo['checkPassphraseCallback'], this.refs['old-passphrase'].getDOMNode().value);
deferredResult.addIf(
[
MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'changePassphrase', this.refs['new-passphrase'].getDOMNode().value),
MochiKit.Base.method(this, function() {
this.refs['username'].getDOMNode().value = '';
this.refs['old-passphrase'].getDOMNode().value = '';
this.refs['new-passphrase'].getDOMNode().value = '';
this.refs['confirm-new-passphrase'].getDOMNode().value = '';
this.setState({'error': ''});
})
],
[MochiKit.Base.bind(this.setState, this, {error: "Invalid password"})]
);
deferredResult.callback();
return deferredResult;
// MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'changePassphrase', this.refs['new-passphrase'].getDOMNode().value);
},
//=========================================================================
render: function () {
var errorVisibility = (this.state.error) ? 'visible' : 'hidden';
return React.DOM.div({className:'extraFeature passphrase'}, [
React.DOM.h1({}, "Change Passphrase"),
React.DOM.form({'key':'form', 'className':'changePassphraseForm', 'onChange': this.handleFormChange, 'onSubmit':this.handleChangePassphrase}, [
React.DOM.div({'key':'fields'},[
// React.DOM.label({'key':'username-label', 'htmlFor' :'name'}, "username"),
// React.DOM.input({'key':'username', 'type':'text', 'name':'name', 'ref':'username', 'placeholder':"username", 'autoCapitalize':'none'}),
// React.DOM.label({'key':'old-passphrase-label', 'htmlFor' :'old-passphrase'}, "old passphrase"),
// React.DOM.input({'key':'old-passphrase', 'type':'password', 'name':'old-passphrase', 'ref':'old-passphrase', 'placeholder':"old passphrase"}),
React.DOM.label({'key':'username-label', 'htmlFor' :'name'}, "username"),
React.DOM.input({'key':'username', 'type':'text', 'name':'name', 'ref':'username', 'placeholder':"username", 'autoCapitalize':'none'}),
React.DOM.label({'key':'old-passphrase-label', 'htmlFor' :'old-passphrase'}, "old passphrase"),
React.DOM.input({'key':'old-passphrase', 'type':'password', 'name':'old-passphrase', 'ref':'old-passphrase', 'placeholder':"old passphrase"}),
React.DOM.label({'key':'new-passphrase-label', 'autoFocus': 'true', 'htmlFor' :'new-passphrase'}, "new passphrase"),
React.DOM.input({'key':'new-passphrase', 'type':'password', 'name':'new-passphrase', 'ref':'new-passphrase', 'placeholder':"new passphrase"}),
React.DOM.label({'key':'confirm-new-passphrase-label', 'htmlFor' :'confirm-new-passphrase'}, "confirm new passphrase"),
React.DOM.input({'key':'confirm-new-passphrase', 'type':'password', 'name':'confirm-new-passphrase', 'ref':'confirm-new-passphrase', 'placeholder':"confirm new passphrase"})
]),
React.DOM.button({'key':'button', 'type':'submit', 'disabled':!this.shouldEnableChangePassphraseButton(), 'className':'button'}, "Change")
React.DOM.button({'key':'button', 'type':'submit', 'disabled':!this.shouldEnableChangePassphraseButton(), 'className':'button'}, "Change"),
React.DOM.div({ref: 'errorMessage', className: 'errorMessage', style: {visibility: errorVisibility} }, this.state.error)
]),
]);
},

View File

@ -34,12 +34,13 @@ Clipperz.PM.UI.Components.Pages.MainPageClass = React.createClass({
},
propTypes: {
'tags': React.PropTypes.object,
'allTags': React.PropTypes.array,
'messageBox': React.PropTypes.object.isRequired,
'featureSet': React.PropTypes.oneOf(['FULL', 'EXPIRED', 'TRIAL']).isRequired,
'features': React.PropTypes.array.isRequired,
'accountInfo': React.PropTypes.object.isRequired,
'tags': React.PropTypes.object,
'allTags': React.PropTypes.array,
'messageBox': React.PropTypes.object.isRequired,
'featureSet': React.PropTypes.oneOf(['FULL', 'EXPIRED', 'TRIAL']).isRequired,
'features': React.PropTypes.array.isRequired,
'userInfo': React.PropTypes.object.isRequired,
'accountInfo': React.PropTypes.object.isRequired,
// 'mediaQueryStyle': React.PropTypes.oneOf(['extra-short', 'narrow', 'wide', 'extra-wide']).isRequired,
'style': React.PropTypes.oneOf(Clipperz_PM_UI_availableStyles).isRequired,
// 'cards': React.PropTypes.deferred.isRequired

View File

@ -143,7 +143,7 @@ Clipperz.PM.UI.Components.Panels.ExtraFeaturesPanelClass = React.createClass({
React.DOM.p({}, "")
])
]),
React.DOM.li({'key':'account_5'}, [
React.DOM.li({'key':'account_5', 'onClick':this.showExtraFeatureComponent('DeleteAccount')}, [
React.DOM.h2({}, "Delete account"),
React.DOM.div({}, [
React.DOM.p({}, "")

View File

@ -62,7 +62,7 @@ Clipperz.PM.UI.MainController = function() {
this.registerForNotificationCenterEvents([
'doLogin', 'registerNewUser', 'showRegistrationForm', 'goBack',
'changePassphrase',
'changePassphrase', 'deleteAccount',
'toggleSelectionPanel', 'toggleSettingsPanel',
'matchMediaQuery', 'unmatchMediaQuery',
'selectAllCards', 'selectRecentCards', 'search', 'tagSelected', 'selectUntaggedCards',
@ -252,6 +252,20 @@ console.log("THE BROWSER IS OFFLINE");
this.overlay().hide();
},
//-------------------------------------------------------------------------
checkPassphrase: function( passphraseIn ) {
var deferredResult;
deferredResult = new Clipperz.Async.Deferred("MainController.deleteAccount_handler", {trace: false});
deferredResult.addMethod(this.user(), 'getPassphrase');
deferredResult.addCallback(function (candidatePassphrase, realPassphrase) { return candidatePassphrase == realPassphrase; }, passphraseIn );
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
showLoginForm: function () {
@ -906,6 +920,20 @@ console.log("THE BROWSER IS OFFLINE");
//.........................................................................
userInfo: function() {
var result;
result = {
'checkPassphraseCallback': MochiKit.Base.bind(this.checkPassphrase,this)
};
if (this.user() != null) {
result['username'] = this.user().username();
}
return result;
},
userAccountInfo: function () {
var result;
@ -985,6 +1013,7 @@ console.log("THE BROWSER IS OFFLINE");
} else if (aPageName == 'mainPage') {
extraProperties = {
'messageBox': this.messageBoxContent(),
'userInfo': this.userInfo(),
'accountInfo': this.userAccountInfo(),
'selectionPanelStatus': this.isSelectionPanelOpen() ? 'OPEN' : 'CLOSED',
'settingsPanelStatus': this.isSettingsPanelOpen() ? 'OPEN' : 'CLOSED',
@ -1229,6 +1258,19 @@ console.log("THE BROWSER IS OFFLINE");
return deferredResult;
},
deleteAccount_handler: function() {
var deferredResult;
deferredResult = new Clipperz.Async.Deferred("MainController.deleteAccount_handler", {trace: false});
deferredResult.addMethod(this.overlay(), 'show', "deleting …", true);
deferredResult.addMethod(this.user(), 'deleteAccount');
deferredResult.addCallback(function() { window.location.href = '/'; });
deferredResult.callback();
return deferredResult;
},
//----------------------------------------------------------------------------

View File

@ -169,6 +169,7 @@
"Clipperz/PM/UI/Components/ExtraFeatures/DevicePIN.js",
"Clipperz/PM/UI/Components/ExtraFeatures/Passphrase.js",
"Clipperz/PM/UI/Components/ExtraFeatures/DeleteAccount.js",
"Clipperz/PM/UI/Components/Cards/FavIcon.js",
"Clipperz/PM/UI/Components/Cards/List.js",

View File

@ -158,16 +158,56 @@ refer to http://www.clipperz.com.
}
.changePassphraseForm {
label {
display: block;
}
}
input {
display: block;
}
}
}
.deleteAccountForm {
margin-top: 1em;
label {
display: block;
}
input {
display: inline-block;
margin-right: 1em;
margin-bottom: 1em;
}
.confirmCheckbox {
display: inline-block;
}
}
form {
input.valid + .invalidMsg, input.empty + .invalidMsg, input:focus + .invalidMsg, input.invalid:focus + .invalidMsg {
visibility: hidden;
}
input:focus {
border: 2px solid $clipperz-orange;
}
input.valid:focus {
border: 2px solid $clipperz-blue;
}
input.invalid + .invalidMsg {
visibility: visible;
}
.invalidMsg::before {
font-family: serif;
content: "\26A0 \0000a0";
}
}
}
}
@ -192,4 +232,4 @@ refer to http://www.clipperz.com.
}
}
}
}
}

View File

@ -37,7 +37,11 @@ class ClipperzTestSite(server.Site):
uri = request.uri
uri = uri.split("?", 1)[0]
uri = uri.split("#", 1)[0]
if uri.startswith('/json') or uri.startswith('/dump'):
if uri == '/':
# This serves the message, but also throws an exception; can't understand why...
result = static.Data('<html>In production you would now be on https://clipperz.is/</html>', 'text/html')
elif uri.startswith('/json') or uri.startswith('/dump'):
resource.prepath = ['app']
result = resource.getChildForRequest(self.resource, request)
elif uri.startswith('/payment'):
@ -116,7 +120,6 @@ class ClipperzTestSite(server.Site):
# print("RESULT\n" + str(result))
return result
def main ():
# site = ClipperzTestSite(proxy.ReverseProxyResource('localhost', 8084, '/java-backend'))
site = ClipperzTestSite(proxy.ReverseProxyResource('localhost', 8084, '/app'))