Skip to content

Commit 962ae45

Browse files
committed
made solidLogicLib exported in UI to be usable in mashlib static + small changes
1 parent 142bd12 commit 962ae45

4 files changed

Lines changed: 25 additions & 51 deletions

File tree

src/create/create.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
**
33
*/
44

5-
// import { logInLoadProfile, selectWorkspace } from '../authn/authn'
65
import { DataBrowserContext, NewPaneOptions, PaneDefinition } from 'pane-registry'
76
import { solidLogicSingleton } from 'solid-logic'
87
import * as debug from '../debug'

src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ import * as participation from './participation'
6161
// @ts-ignore
6262
import * as preferences from './preferences'
6363
// @ts-ignore
64-
import { solidLogicSingleton } from 'solid-logic'
6564
// @ts-ignore
6665
import * as style from './style'
6766
// @ts-ignore
@@ -74,18 +73,20 @@ import * as widgets from './widgets/index'
7473
import versionInfo from './versionInfo'
7574
import { initHeader } from './header'
7675
import { initFooter } from './footer'
76+
import * as createTypes from './create/types'
77+
import * as solidLogicLib from 'solid-logic'
7778

7879
const dom = window ? window.document : null // Idea that UI.dom can be adapted in non-browser environments
79-
const store = solidLogicSingleton.store
8080

8181
if (typeof window !== 'undefined') {
8282
;(<any>window).UI = {
83+
solidLogicLib,
8384
ns,
8485
rdf,
8586
acl,
8687
aclControl,
87-
// authn,
8888
create,
89+
createTypes,
8990
dom,
9091
icons,
9192
language,
@@ -98,7 +99,6 @@ if (typeof window !== 'undefined') {
9899
pad,
99100
participation,
100101
preferences,
101-
store,
102102
style,
103103
table,
104104
tabs,
@@ -111,12 +111,13 @@ if (typeof window !== 'undefined') {
111111
}
112112

113113
export {
114+
solidLogicLib,
114115
ns,
115116
rdf,
116117
acl,
117118
aclControl,
118-
// authn,
119119
create,
120+
createTypes,
120121
dom,
121122
icons,
122123
language,
@@ -129,7 +130,6 @@ export {
129130
pad,
130131
participation,
131132
preferences,
132-
store,
133133
style,
134134
table,
135135
tabs,

src/login/login.ts

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function loggedInContext (context: AuthenticationContext): Promise<Authen
4949
authn.checkUser().then(webId => {
5050
// Already logged in?
5151
if (webId) {
52-
debug.log(`logIn: Already logged in as ${context.me}`)
52+
debug.log(`logIn: Already logged in as ${webId}`)
5353
return resolve(context)
5454
}
5555
if (!context.div || !context.dom) {
@@ -448,9 +448,12 @@ function signInOrSignUpBox (
448448
signInPopUpButton.setAttribute('style', `${signInButtonStyle}background-color: #eef;`)
449449

450450
authSession.onLogin(() => {
451-
const sessionInfo = authSession.info
452-
if (sessionInfo && sessionInfo.isLoggedIn) {
453-
const webIdURI = sessionInfo.webId
451+
const me = authn.currentUser()
452+
// const sessionInfo = authSession.info
453+
// if (sessionInfo && sessionInfo.isLoggedIn) {
454+
if (me) {
455+
// const webIdURI = sessionInfo.webId
456+
const webIdURI = me.uri
454457
// setUserCallback(webIdURI)
455458
const divs = dom.getElementsByClassName(magicClassName)
456459
debug.log(`Logged in, ${divs.length} panels to be serviced`)
@@ -498,27 +501,6 @@ function signInOrSignUpBox (
498501
return box
499502
}
500503

501-
// ======== WHAT IS THIS? ========
502-
authSession.onLogout(async () => {
503-
const issuer = window.localStorage.getItem('loginIssuer')
504-
if (issuer) {
505-
try {
506-
const wellKnownUri = new URL(issuer)
507-
wellKnownUri.pathname = '/.well-known/openid-configuration'
508-
const wellKnownResult = await fetch(wellKnownUri.toString())
509-
if (wellKnownResult.status === 200) {
510-
const openidConfiguration = await wellKnownResult.json()
511-
if (openidConfiguration && openidConfiguration.end_session_endpoint) {
512-
await fetch(openidConfiguration.end_session_endpoint, { credentials: 'include' })
513-
}
514-
}
515-
} catch (err) {
516-
// Do nothing
517-
}
518-
}
519-
window.location.reload()
520-
})
521-
522504
export function renderSignInPopup (dom: HTMLDocument) {
523505
/**
524506
* Issuer Menu
@@ -664,17 +646,18 @@ export function loginStatusBox (
664646
return
665647
}
666648

667-
const uri = newidURI.uri || newidURI
668-
me = sym(uri)
649+
// const uri = newidURI.uri || newidURI
650+
// me = sym(uri)
651+
me = authn.saveUser(newidURI)
669652
box.refresh()
670-
if (listener) listener(me.uri)
653+
if (listener) listener(me!.uri)
671654
}
672655

673656
function logoutButtonHandler (_event) {
674-
// UI.preferences.set('me', '')
657+
const oldMe = me
675658
authSession.logout().then(
676659
function () {
677-
const message = `Your WebID was ${me}. It has been forgotten.`
660+
const message = `Your WebID was ${oldMe}. It has been forgotten.`
678661
me = null
679662
try {
680663
alert(message)
@@ -711,12 +694,7 @@ export function loginStatusBox (
711694
}
712695

713696
box.refresh = function () {
714-
const sessionInfo = authSession.info
715-
if (sessionInfo && sessionInfo.webId && sessionInfo.isLoggedIn) {
716-
me = sym(sessionInfo.webId)
717-
} else {
718-
me = null
719-
}
697+
me = authn.currentUser()
720698
if ((me && box.me !== me.uri) || (!me && box.me)) {
721699
widgets.clearElement(box)
722700
if (me) {
@@ -727,20 +705,16 @@ export function loginStatusBox (
727705
}
728706
box.me = me ? me.uri : null
729707
}
708+
box.refresh()
730709

731710
function trackSession () {
732-
const sessionInfo = authSession.info
733-
if (sessionInfo && sessionInfo.webId && sessionInfo.isLoggedIn) {
734-
me = sym(sessionInfo.webId)
735-
} else {
736-
me = null
737-
}
711+
me = authn.currentUser()
738712
box.refresh()
739713
}
740714
trackSession()
715+
741716
authSession.onLogin(trackSession)
742717
authSession.onLogout(trackSession)
743-
744718
box.me = '99999' // Force refresh
745719
box.refresh()
746720
return box

test/unit/index.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe('Index', () => {
99
'acl',
1010
'aclControl',
1111
'create',
12+
'createTypes',
1213
'dom',
1314
'icons',
1415
'infiniteMessageArea',
@@ -25,7 +26,7 @@ describe('Index', () => {
2526
'participation',
2627
'preferences',
2728
'rdf',
28-
'store',
29+
'solidLogicLib',
2930
'style',
3031
'table',
3132
'tabs',

0 commit comments

Comments
 (0)