mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Remove client-side support for protocol version 1.
This commit is contained in:
parent
a845e9f722
commit
a701d8c6fa
2 changed files with 11 additions and 27 deletions
|
@ -3164,23 +3164,15 @@ function parseExpiration(s) {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
function protocol2Predicate() {
|
|
||||||
if(serverConnection.version === "1")
|
|
||||||
return "This server is too old";
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeTokenPredicate() {
|
function makeTokenPredicate() {
|
||||||
return protocol2Predicate() ||
|
return (serverConnection.permissions.indexOf('token') < 0 ?
|
||||||
(serverConnection.permissions.indexOf('token') < 0 ?
|
"You don't have permission to create tokens" : null);
|
||||||
"You don't have permission to create tokens" : null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function editTokenPredicate() {
|
function editTokenPredicate() {
|
||||||
return protocol2Predicate() ||
|
return (serverConnection.permissions.indexOf('token') < 0 ||
|
||||||
(serverConnection.permissions.indexOf('token') < 0 ||
|
serverConnection.permissions.indexOf('op') < 0 ?
|
||||||
serverConnection.permissions.indexOf('op') < 0 ?
|
"You don't have permission to edit or list tokens" : null);
|
||||||
"You don't have permission to edit or list tokens" : null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -298,7 +298,7 @@ ServerConnection.prototype.connect = async function(url) {
|
||||||
this.socket.onopen = function(e) {
|
this.socket.onopen = function(e) {
|
||||||
sc.send({
|
sc.send({
|
||||||
type: 'handshake',
|
type: 'handshake',
|
||||||
version: ["2", "1"],
|
version: ["2"],
|
||||||
id: sc.id,
|
id: sc.id,
|
||||||
});
|
});
|
||||||
if(sc.onconnected)
|
if(sc.onconnected)
|
||||||
|
@ -332,19 +332,11 @@ ServerConnection.prototype.connect = async function(url) {
|
||||||
let m = JSON.parse(e.data);
|
let m = JSON.parse(e.data);
|
||||||
switch(m.type) {
|
switch(m.type) {
|
||||||
case 'handshake': {
|
case 'handshake': {
|
||||||
/** @type {string} */
|
if(m.version === "2")
|
||||||
let v;
|
sc.version = m.version;
|
||||||
if(!m.version || !(m.version instanceof Array) ||
|
else {
|
||||||
m.version.length < 1 || typeof(m.version[0]) !== 'string') {
|
console.error(`Unknown protocol version ${m.version}`);
|
||||||
v = null;
|
throw new Error(`Unknown protocol version ${m.version}`);
|
||||||
} else {
|
|
||||||
v = m.version[0];
|
|
||||||
}
|
|
||||||
if(v === "1" || v === "2") {
|
|
||||||
sc.version = v;
|
|
||||||
} else {
|
|
||||||
console.warn(`Unknown protocol version ${v || m.version}`);
|
|
||||||
sc.version = "1"
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue