Skip to content

Commit

Permalink
Merge branch 'hotfix/v1.0.1' of github.com:ONLYOFFICE/AppServer into …
Browse files Browse the repository at this point in the history
…hotfix/v1.0.1
  • Loading branch information
TatianaLopaeva committed Nov 11, 2021
2 parents 53cb682 + 0006d42 commit 3a03d65
Show file tree
Hide file tree
Showing 42 changed files with 1,257 additions and 93 deletions.
19 changes: 19 additions & 0 deletions packages/asc-web-common/api/people/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { request } from "../client";
//import axios from "axios";
import Filter from "./filter";
import * as fakePeople from "./fake";
import { Encoder } from "../../utils/encoder";

export function getUserList(filter = Filter.getDefault(), fake = false) {
if (fake) {
Expand All @@ -18,6 +19,14 @@ export function getUserList(filter = Filter.getDefault(), fake = false) {
return request({
method: "get",
url: `/people${params}`,
}).then((res) => {
res.items = res.items.map((user) => {
if (user && user.displayName) {
user.displayName = Encoder.htmlDecode(user.displayName);
}
return user;
});
return res;
});
}

Expand All @@ -26,6 +35,11 @@ export function getUser(userName = null) {
method: "get",
url: `/people/${userName || "@self"}.json`,
skipUnauthorized: true,
}).then((user) => {
if (user && user.displayName) {
user.displayName = Encoder.htmlDecode(user.displayName);
}
return user;
});
}
export function getUserPhoto(userId) {
Expand Down Expand Up @@ -156,6 +170,11 @@ export function updateUserCulture(id, cultureName) {
method: "put",
url: `/people/${id}/culture`,
data: { cultureName },
}).then((user) => {
if (user && user.displayName) {
user.displayName = Encoder.htmlDecode(user.displayName);
}
return user;
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/asc-web-common/components/PageLayout/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ i18n
.init({
lng: localStorage.getItem(LANGUAGE) || "en",
fallbackLng: "en",
load: "all",
load: "currentOnly",
//debug: true,

interpolation: {
Expand Down
33 changes: 17 additions & 16 deletions packages/asc-web-common/store/AuthStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class AuthStore {
tfaStore = null;

isLoading = false;
isAuthenticated = false;
version = null;
skipModules = false;
providers = [];
Expand All @@ -42,8 +41,6 @@ class AuthStore {

await this.userStore.init();

if (this.userStore.user) this.setIsAuthenticated(true);

const requests = [];
requests.push(this.settingsStore.init());

Expand Down Expand Up @@ -202,15 +199,17 @@ class AuthStore {
}
};

reset = () => {
reset = (skipUser = false) => {
this.isInit = false;
this.skipModules = false;
this.userStore = new UserStore();
if (!skipUser) {
this.userStore = new UserStore();
}
this.moduleStore = new ModuleStore();
this.settingsStore = new SettingsStore();
};

logout = async (withoutRedirect) => {
logout = async (redirectToLogin = true) => {
await api.user.logout();

//console.log("Logout response ", response);
Expand All @@ -221,22 +220,24 @@ class AuthStore {

isDesktop && logoutDesktop();

this.reset();

this.init();

if (!withoutRedirect) {
if (redirectToLogin) {
if (personal) {
window.location.replace("/");
return window.location.replace("/");
} else {
history.push(combineUrl(proxyURL, "/login"));
this.reset(true);
this.userStore.setUser(null);
this.init();
return history.push(combineUrl(proxyURL, "/login"));
}
} else {
this.reset();
this.init();
}
};

setIsAuthenticated = (isAuthenticated) => {
this.isAuthenticated = isAuthenticated;
};
get isAuthenticated() {
return this.userStore.isAuthenticated;
}

getEncryptionAccess = (fileId) => {
return api.files
Expand Down
25 changes: 10 additions & 15 deletions packages/asc-web-common/store/UserStore.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { action, makeObservable, observable } from "mobx";
import { makeAutoObservable } from "mobx";
import api from "../api";

class UserStore {
Expand All @@ -8,29 +8,20 @@ class UserStore {
userIsUpdate = false;

constructor() {
makeObservable(this, {
user: observable,
isLoading: observable,
isLoaded: observable,
userIsUpdate: observable,
getCurrentUser: action,
setIsLoading: action,
setIsLoaded: action,
setUser: action,
setUserIsUpdate: action,
});
makeAutoObservable(this);
}

getCurrentUser = async () => {
loadCurrentUser = async () => {
const user = await api.people.getUser();

this.setUser(user);
};

init = async () => {
if (this.isLoaded) return;

this.setIsLoading(true);

await this.getCurrentUser();
await this.loadCurrentUser();

this.setIsLoading(false);
this.setIsLoaded(true);
Expand Down Expand Up @@ -61,6 +52,10 @@ class UserStore {
//console.log("setUserIsUpdate");
this.userIsUpdate = isUpdate;
};

get isAuthenticated() {
return !!this.user;
}
}

export default UserStore;
Loading

0 comments on commit 3a03d65

Please sign in to comment.