Addressing issues from group code review
Этот коммит содержится в:
@@ -23,6 +23,7 @@ class BrowserStoreClass {
|
||||
this.getLastServerVersion = this.getLastServerVersion.bind(this);
|
||||
this.setLastServerVersion = this.setLastServerVersion.bind(this);
|
||||
this.clear = this.clear.bind(this);
|
||||
this.clearAll = this.clearAll.bind(this);
|
||||
|
||||
var currentVersion = sessionStorage.getItem('storage_version');
|
||||
if (currentVersion !== global.window.mm_config.Version) {
|
||||
@@ -57,13 +58,14 @@ class BrowserStoreClass {
|
||||
setGlobalItem(name, value) {
|
||||
try {
|
||||
if (this.isLocalStorageSupported()) {
|
||||
localStorage.setItem(name, JSON.stringify(value));
|
||||
localStorage.setItem(getPrefix() + name, JSON.stringify(value));
|
||||
} else {
|
||||
sessionStorage.setItem(name, JSON.stringify(value));
|
||||
sessionStorage.setItem(getPrefix() + name, JSON.stringify(value));
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('An error occurred while setting local storage, clearing all props'); //eslint-disable-line no-console
|
||||
localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
window.location.href = window.location.href;
|
||||
}
|
||||
}
|
||||
@@ -72,9 +74,9 @@ class BrowserStoreClass {
|
||||
var result = null;
|
||||
try {
|
||||
if (this.isLocalStorageSupported()) {
|
||||
result = JSON.parse(localStorage.getItem(name));
|
||||
result = JSON.parse(getPrefix() + localStorage.getItem(name));
|
||||
} else {
|
||||
result = JSON.parse(sessionStorage.getItem(name));
|
||||
result = JSON.parse(getPrefix() + sessionStorage.getItem(name));
|
||||
}
|
||||
} catch (err) {
|
||||
result = null;
|
||||
@@ -89,9 +91,9 @@ class BrowserStoreClass {
|
||||
|
||||
removeGlobalItem(name) {
|
||||
if (this.isLocalStorageSupported()) {
|
||||
localStorage.removeItem(name);
|
||||
localStorage.removeItem(getPrefix() + name);
|
||||
} else {
|
||||
sessionStorage.removeItem(name);
|
||||
sessionStorage.removeItem(getPrefix() + name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +112,13 @@ class BrowserStoreClass {
|
||||
actionOnGlobalItemsWithPrefix(prefix, action) {
|
||||
var globalPrefix = getPrefix();
|
||||
var globalPrefixiLen = globalPrefix.length;
|
||||
for (var key in localStorage) {
|
||||
|
||||
var storage = sessionStorage;
|
||||
if (this.isLocalStorageSupported()) {
|
||||
storage = localStorage;
|
||||
}
|
||||
|
||||
for (var key in storage) {
|
||||
if (key.lastIndexOf(globalPrefix + prefix, 0) === 0) {
|
||||
var userkey = key.substring(globalPrefixiLen);
|
||||
action(userkey, this.getGlobalItem(key));
|
||||
@@ -133,6 +141,11 @@ class BrowserStoreClass {
|
||||
sessionStorage.clear();
|
||||
}
|
||||
|
||||
clearAll() {
|
||||
sessionStorage.clear();
|
||||
localStorage.clear();
|
||||
}
|
||||
|
||||
isLocalStorageSupported() {
|
||||
try {
|
||||
sessionStorage.setItem('testSession', '1');
|
||||
|
||||
@@ -1026,7 +1026,6 @@ func incomingWebhook(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// create a mock session
|
||||
c.Session = model.Session{UserId: hook.UserId, TeamId: hook.TeamId, IsOAuth: false}
|
||||
c.SessionTokenIndex = 0
|
||||
|
||||
if !c.HasPermissionsToChannel(pchan, "createIncomingHook") && channel.Type != model.CHANNEL_OPEN {
|
||||
c.Err = model.NewAppError("incomingWebhook", "Inappropriate channel permissions", "")
|
||||
|
||||
Ссылка в новой задаче
Block a user