2
0

Fix log-in after entering the wrong master password.

This commit is contained in:
Maarten Billemont 2014-12-31 13:53:28 -05:00
parent 83fcde5bd0
commit 778533ac7f
2 changed files with 18 additions and 3 deletions

View File

@ -58,12 +58,19 @@ public class ModelUser extends User {
if (!model.hasKeyID()) {
model.setKeyID( key.getKeyID() );
MPUserFileManager.get().save();
} else if (!model.hasKeyID( key.getKeyID() ))
} else if (!model.hasKeyID( key.getKeyID() )) {
reset();
throw new MasterKeyException( strf( "Incorrect master password for user: %s", getFullName() ) );
}
return key;
}
@Override
public void reset() {
masterPassword = null;
}
@Override
public Iterable<Site> findSitesByName(final String query) {
return FluentIterable.from( model.findSitesByName( query ) ).transform( new Function<MPSiteResult, Site>() {

View File

@ -32,14 +32,22 @@ public abstract class User {
@Nonnull
public MasterKey getKey() throws MasterKeyException {
if (key == null) {
if (!hasKey())
String masterPassword = getMasterPassword();
if (masterPassword == null || masterPassword.isEmpty()) {
reset();
throw new MasterKeyException( strf( "Master password unknown for user: %s", getFullName() ) );
key = new MasterKey( getFullName(), getMasterPassword() );
}
key = new MasterKey( getFullName(), masterPassword );
}
return key;
}
public void reset() {
key = null;
}
public abstract Iterable<Site> findSitesByName(final String siteName);
public abstract void addSite(final Site site);