Skip to content

Commit db60fdb

Browse files
committed
loggedIn property
1 parent 9f5f947 commit db60fdb

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

services/static-webserver/client/source/class/osparc/TooSmallDialog.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ qx.Class.define("osparc.TooSmallDialog", {
6969
button.addListener("execute", () => qx.core.Init.getApplication().logout());
7070
layout.add(button);
7171

72-
const isLoggedIn = osparc.auth.Manager.getInstance().isLoggedIn();
73-
layout.setVisibility(isLoggedIn ? "visible" : "excluded");
72+
const authManager = osparc.auth.Manager.getInstance();
73+
authManager.bind("loggedIn", layout, "visibility", {
74+
converter: isLoggedIn => isLoggedIn ? "visible" : "excluded"
75+
});
7476

7577
return layout;
7678
},

services/static-webserver/client/source/class/osparc/auth/Manager.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,28 @@ qx.Class.define("osparc.auth.Manager", {
2626
extend: qx.core.Object,
2727
type: "singleton",
2828

29-
/*
30-
*****************************************************************************
31-
EVENTS
32-
*****************************************************************************
33-
*/
29+
construct: function() {
30+
// TODO: how to store this locally?? See http://www.qooxdoo.org/devel/pages/data_binding/stores.html#offline-store
31+
// TODO: check if expired??
32+
// TODO: request server if token is still valid (e.g. expired, etc)
33+
const authData = osparc.auth.Data.getInstance();
34+
authData.bind("auth", this, "loggedIn", {
35+
converter: auth => auth !== null && auth instanceof osparc.io.request.authentication.Token
36+
});
37+
},
3438

3539
events: {
3640
"loggedOut": "qx.event.type.Event"
3741
},
3842

39-
40-
/*
41-
*****************************************************************************
42-
MEMBERS
43-
*****************************************************************************
44-
*/
43+
properties: {
44+
loggedIn: {
45+
check: "Boolean",
46+
nullable: false,
47+
init: false,
48+
event: "changeLoggedIn",
49+
}
50+
},
4551

4652
members: {
4753
register: function(userData) {
@@ -129,14 +135,6 @@ qx.Class.define("osparc.auth.Manager", {
129135
return osparc.data.Resources.fetch("auth", "resendCode", params);
130136
},
131137

132-
isLoggedIn: function() {
133-
// TODO: how to store this locally?? See http://www.qooxdoo.org/devel/pages/data_binding/stores.html#offline-store
134-
// TODO: check if expired??
135-
// TODO: request server if token is still valid (e.g. expired, etc)
136-
const auth = osparc.auth.Data.getInstance().getAuth();
137-
return auth !== null && auth instanceof osparc.io.request.authentication.Token;
138-
},
139-
140138
/*
141139
* Function that checks if there is a token and validates it against the server.
142140
*/

0 commit comments

Comments
 (0)