Fix log-in after entering the wrong master password.
This commit is contained in:
parent
83fcde5bd0
commit
778533ac7f
@ -58,12 +58,19 @@ public class ModelUser extends User {
|
|||||||
if (!model.hasKeyID()) {
|
if (!model.hasKeyID()) {
|
||||||
model.setKeyID( key.getKeyID() );
|
model.setKeyID( key.getKeyID() );
|
||||||
MPUserFileManager.get().save();
|
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() ) );
|
throw new MasterKeyException( strf( "Incorrect master password for user: %s", getFullName() ) );
|
||||||
|
}
|
||||||
|
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
masterPassword = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<Site> findSitesByName(final String query) {
|
public Iterable<Site> findSitesByName(final String query) {
|
||||||
return FluentIterable.from( model.findSitesByName( query ) ).transform( new Function<MPSiteResult, Site>() {
|
return FluentIterable.from( model.findSitesByName( query ) ).transform( new Function<MPSiteResult, Site>() {
|
||||||
|
@ -32,14 +32,22 @@ public abstract class User {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
public MasterKey getKey() throws MasterKeyException {
|
public MasterKey getKey() throws MasterKeyException {
|
||||||
if (key == null) {
|
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() ) );
|
throw new MasterKeyException( strf( "Master password unknown for user: %s", getFullName() ) );
|
||||||
key = new MasterKey( getFullName(), getMasterPassword() );
|
}
|
||||||
|
|
||||||
|
key = new MasterKey( getFullName(), masterPassword );
|
||||||
}
|
}
|
||||||
|
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
key = null;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract Iterable<Site> findSitesByName(final String siteName);
|
public abstract Iterable<Site> findSitesByName(final String siteName);
|
||||||
|
|
||||||
public abstract void addSite(final Site site);
|
public abstract void addSite(final Site site);
|
||||||
|
Loading…
Reference in New Issue
Block a user