2022-01-22 03:01:40 +00:00
|
|
|
const credentials = await import('../credentials.js');
|
2021-12-01 10:54:41 +00:00
|
|
|
|
|
|
|
converse.plugins.add('converse-desktop-credentials', {
|
|
|
|
|
2022-03-28 19:25:49 +00:00
|
|
|
initialize() {
|
|
|
|
const {_converse} = this;
|
|
|
|
const {api} = _converse;
|
2021-12-01 10:54:41 +00:00
|
|
|
|
|
|
|
api.listen.on('afterResourceBinding', () => {
|
|
|
|
if (_converse.connection.pass) {
|
2022-01-22 03:01:40 +00:00
|
|
|
credentials.addCredentials(
|
2022-03-26 03:17:38 +00:00
|
|
|
_converse.connection.service,
|
2021-12-01 10:54:41 +00:00
|
|
|
_converse.bare_jid,
|
|
|
|
_converse.connection.pass
|
2022-03-28 19:25:49 +00:00
|
|
|
).catch((reason) => {
|
|
|
|
console.log(reason);
|
|
|
|
});
|
2021-12-01 10:54:41 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
api.listen.on('logout', () => {
|
2022-01-22 03:01:40 +00:00
|
|
|
credentials.getCredentials().then((result) => credentials.removeCredentials(result.login))
|
2021-12-01 10:54:41 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|