mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-10-29 19:57:28 +00:00
Merge pull request #769 from igniterealtime/save-password-from-preference-panel
SPARK-2320 Save password from Preferences menu
This commit is contained in:
commit
6bd4ee9f3d
@ -1395,7 +1395,7 @@ public class LoginUIPanel extends javax.swing.JPanel implements KeyListener, Act
|
||||
// Check to see if the password should be saved or cleared from file.
|
||||
if (savePasswordAfterSuccessfulLogin.get()) {
|
||||
try {
|
||||
localPref.setPasswordForUser(getLoginUsername() + "@" + getLoginServer(), getLoginPassword());
|
||||
localPref.setPasswordForUser(getBareJid(), getLoginPassword());
|
||||
} catch (Exception e) {
|
||||
Log.error("Error storing encrypted password.", e);
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ import javax.swing.JTextField;
|
||||
import org.jivesoftware.Spark;
|
||||
import org.jivesoftware.resource.Default;
|
||||
import org.jivesoftware.resource.Res;
|
||||
import org.jivesoftware.spark.SparkManager;
|
||||
import org.jivesoftware.spark.component.VerticalFlowLayout;
|
||||
import org.jivesoftware.spark.util.ResourceUtils;
|
||||
import org.jivesoftware.spark.util.log.Log;
|
||||
@ -78,7 +79,16 @@ public class LocalPreferencePanel extends JPanel {
|
||||
} else {
|
||||
_savePasswordBox.addActionListener(e -> {
|
||||
_autoLoginBox.setEnabled(_savePasswordBox.isSelected());
|
||||
if (!_savePasswordBox.isSelected()) {
|
||||
if (_savePasswordBox.isSelected()) {
|
||||
String user = SparkManager.getSessionManager().getUserBareAddress().toString();
|
||||
String password = SparkManager.getSessionManager().getPassword();
|
||||
try {
|
||||
preferences.setPasswordForUser(user,password);
|
||||
} catch (Exception ex) {
|
||||
Log.error("Error storing encrypted password.", ex);
|
||||
}
|
||||
}
|
||||
if (!_savePasswordBox.isSelected()) {
|
||||
_autoLoginBox.setSelected(false);
|
||||
try {
|
||||
preferences.clearPasswordForAllUsers();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user